diff options
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 |
commit | a156e55302d7ce35234b6075124d2b5ed4037c89 (patch) | |
tree | 51bf87c71bcd71dff92a6f5bbe36bbcd2fe15951 /src/main.c | |
parent | a8f06005be7e61f0562d8c36d953f688922edf01 (diff) | |
download | conntrack-tools-a156e55302d7ce35234b6075124d2b5ed4037c89.tar.gz conntrack-tools-a156e55302d7ce35234b6075124d2b5ed4037c89.zip |
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.c | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -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); |