aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-01-22 21:33:56 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2006-01-22 21:33:56 +0100
commita49dcd5c3c6b79470ad71dc45ccf29f65ba2a7f9 (patch)
tree06a4d77f23d88d7c0c9fd4193e4f29324383dcf0
parent57c4fc067a4a43cebee74e9d6076eb538986d5cc (diff)
Fixed the bug that caused a fork() bomb last night.
-rw-r--r--bitlbee.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/bitlbee.c b/bitlbee.c
index 5da5d6e1..2f757f53 100644
--- a/bitlbee.c
+++ b/bitlbee.c
@@ -103,10 +103,14 @@ 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