summaryrefslogtreecommitdiffstats
path: root/src/main.c
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-17 17:10:40 +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-17 17:10:40 +0000
commita156e55302d7ce35234b6075124d2b5ed4037c89 (patch)
tree51bf87c71bcd71dff92a6f5bbe36bbcd2fe15951 /src/main.c
parenta8f06005be7e61f0562d8c36d953f688922edf01 (diff)
Max Kellerman <max@duempel.org>:
o always close stdin - even in non-daemon mode, it is of no use o chdir("/") to release the cwd inode o ignore setsid() failure, because there is only one possible and o fix harmless error condition
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index a4ee307..b860982 100644
--- a/src/main.c
+++ b/src/main.c
@@ -284,9 +284,12 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ chdir("/");
+ close(STDIN_FILENO);
+
/* Daemonize conntrackd */
if (type == DAEMON) {
- pid_t pid, sid;
+ pid_t pid;
if ((pid = fork()) == -1) {
perror("fork has failed: ");
@@ -294,14 +297,8 @@ int main(int argc, char *argv[])
} else if (pid)
exit(EXIT_SUCCESS);
- sid = setsid();
-
- if (sid < 0) {
- perror("setsid has failed: ");
- exit(EXIT_FAILURE);
- }
+ setsid();
- close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);