diff options
author | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-16 10:45:26 +0000 |
---|---|---|
committer | Wilmer van der Gaast <wilmer@gaast.net> | 2010-03-16 10:45:26 +0000 |
commit | 0b510af4fc35c08e7eb693c018c9db141916970a (patch) | |
tree | 02eb4390f402e249073ece07ce2e9261d34ad090 /bitlbee.c | |
parent | ec55a7d76711d6b071e0d1ba043cb120d3e11c24 (diff) |
Check the RESTART environment variable before closing fd's 0-2 since the
previous approach broke upgrades to bzr >= 500.
Diffstat (limited to 'bitlbee.c')
-rw-r--r-- | bitlbee.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -108,17 +108,13 @@ int bitlbee_daemon_init() chdir( "/" ); - i = close( 0 ) == 0; - i += close( 1 ) == 0; - i += close( 2 ) == 0; - /* To avoid that something important ends up on one of those - fd's, open them for something bogus. Otherwise RESTART - may cause troubles. */ - while( i > 0 ) - { - open( "/dev/null", O_WRONLY ); - i --; - } + if( getenv( "_BITLBEE_RESTART_STATE" ) == NULL ) + for( i = 0; i < 3; i ++ ) + if( close( i ) == 0 ) + { + /* Keep something bogus on those fd's just in case. */ + open( "/dev/null", O_WRONLY ); + } } #endif |