diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-02-02 14:59:14 +0100 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-02-02 14:59:14 +0100 |
commit | 1d2e3c2ee2fb4c12ad25832b93ae9513d042717a (patch) | |
tree | ea7c2a7a03f39ae8dcb1de0d98d35aaa6c7b19d3 /bitlbee.c | |
parent | 34b17d9b8901b72439167b99d780c481ce420e33 (diff) | |
parent | a49dcd5c3c6b79470ad71dc45ccf29f65ba2a7f9 (diff) |
Added RESTART command for easier upgrades without losing IPC connections.
(Obviously only works well for forking daemon mode.)
Diffstat (limited to 'bitlbee.c')
-rw-r--r-- | bitlbee.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -104,13 +104,20 @@ int bitlbee_daemon_init() } else if( i != 0 ) exit( 0 ); - close( 0 ); - close( 1 ); - close( 2 ); + chdir( "/" ); + + /* Sometimes std* are already closed (for example when we're in a RESTARTed + BitlBee process. So let's only close TTY-fds. */ + if( isatty( 0 ) ) close( 0 ); + if( isatty( 0 ) ) close( 1 ); + if( isatty( 0 ) ) close( 2 ); } #endif + if( global.conf->runmode == RUNMODE_FORKDAEMON ) + ipc_master_load_state(); + if( ( fp = fopen( global.conf->pidfile, "w" ) ) ) { fprintf( fp, "%d\n", (int) getpid() ); @@ -246,6 +253,12 @@ gboolean bitlbee_io_new_client( GIOChannel *source, GIOCondition condition, gpoi int new_socket = accept( global.listen_socket, (struct sockaddr *) &conn_info, &size ); pid_t client_pid = 0; + if( new_socket == -1 ) + { + log_message( LOGLVL_WARNING, "Could not accept new connection: %s", strerror( errno ) ); + return TRUE; + } + if( global.conf->runmode == RUNMODE_FORKDAEMON ) { int fds[2]; |