aboutsummaryrefslogtreecommitdiffstats
path: root/bitlbee.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-03-14 16:35:55 +0000
committerWilmer van der Gaast <wilmer@gaast.net>2010-03-14 16:35:55 +0000
commitbb3477107afcc6f532758bb08c4677d62e17ee57 (patch)
tree33ce117129166ad30b8aa17ca072a92a4a3acc8e /bitlbee.c
parent286b28eabf39d98d642c73c34a16a599e61dfc99 (diff)
Close fd's 0,1,2 no matter what, not just if they're ttys. (Bug #476)
Diffstat (limited to 'bitlbee.c')
-rw-r--r--bitlbee.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/bitlbee.c b/bitlbee.c
index b31c31fe..a96cff03 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -108,11 +108,17 @@ int bitlbee_daemon_init()
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( 1 ) ) close( 1 );
- if( isatty( 2 ) ) close( 2 );
+ 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 --;
+ }
}
#endif