summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-05 14:37:07 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-05 14:37:07 +0000
commit18d19a287315b950a6cef6051f8d4e844e37c6ba (patch)
tree5c73e63d97f6508c8fec8cd56d31b4086f06e7d1 /src
parente55426322935d8895a4852b7adf7fba115ac591a (diff)
daemonize conntrackd after initialization
Diffstat (limited to 'src')
-rw-r--r--src/main.c28
1 files changed, 16 insertions, 12 deletions
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();