summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
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);