diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/main.c | 9 |
2 files changed, 9 insertions, 1 deletions
@@ -27,6 +27,7 @@ o show error and warning messages to stderr o hash lookup speedups based on comments from netdev's discussions o add support for connection logging to the statistics mode via Logfile o minor irrelevant fixes for uncommon error paths and fix several typos +o detach daemon from its terminal (Ben Lenitz <BLentz@channing-bete.com>) version 0.9.5 (2007/07/29) ------------------------------ @@ -272,7 +272,7 @@ int main(int argc, char *argv[]) /* Daemonize conntrackd */ if (type == DAEMON) { - pid_t pid; + pid_t pid, sid; if ((pid = fork()) == -1) { perror("fork has failed: "); @@ -280,6 +280,13 @@ int main(int argc, char *argv[]) } else if (pid) exit(EXIT_SUCCESS); + sid = setsid(); + + if (sid < 0) { + perror("setsid has failed: "); + exit(EXIT_FAILURE); + } + dlog(STATE(log), LOG_NOTICE, "-- starting in daemon mode --"); } else dlog(STATE(log), LOG_NOTICE, "-- starting in console mode --"); |