summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/main.c28
2 files changed, 17 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index d9c9411..34ad928 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,7 @@ 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>)
o obsolete `-S' option: Use information provided by the config file
+o daemonize conntrackd after initialization
version 0.9.5 (2007/07/29)
------------------------------
diff --git a/src/main.c b/src/main.c
index c8b1074..3cf44ba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -270,6 +270,18 @@ int main(int argc, char *argv[])
}
close(ret);
+ /*
+ * initialization process
+ */
+
+ if (init() == -1) {
+ close_log();
+ fprintf(stderr, "ERROR: conntrackd cannot start, please "
+ "check the logfile for more info\n");
+ unlink(CONFIG(lockfile));
+ exit(EXIT_FAILURE);
+ }
+
/* Daemonize conntrackd */
if (type == DAEMON) {
pid_t pid, sid;
@@ -287,23 +299,15 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ close(STDIN_FILENO);
+ close(STDOUT_FILENO);
+ close(STDERR_FILENO);
+
dlog(STATE(log), LOG_NOTICE, "-- starting in daemon mode --");
} else
dlog(STATE(log), LOG_NOTICE, "-- starting in console mode --");
/*
- * initialization process
- */
-
- if (init() == -1) {
- close_log();
- fprintf(stderr, "ERROR: conntrackd cannot start, please "
- "check the logfile for more info\n");
- unlink(CONFIG(lockfile));
- exit(EXIT_FAILURE);
- }
-
- /*
* run main process
*/
run();