diff options
author | Guillem Jover <guillem@debian.org> | 2014-09-09 14:47:39 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-10-06 00:40:43 +0200 |
commit | 877057869d5ae7cc3a0c7911ab905275b41d1d09 (patch) | |
tree | a7ea0e31cd6ffae2c94e251b680dae2de59298d8 /utils | |
parent | 1fab3f69a9c8991c3431a0cca3e49446f6a161e2 (diff) | |
download | dpkg-877057869d5ae7cc3a0c7911ab905275b41d1d09.tar.gz |
s-s-d: Abort if the system or compatibility setsid() fails
This requires to check the setpgid() return value in the setsid()
compatibility function.
Diffstat (limited to 'utils')
-rw-r--r-- | utils/start-stop-daemon.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c index 93850e308..d3c5d826d 100644 --- a/utils/start-stop-daemon.c +++ b/utils/start-stop-daemon.c @@ -352,7 +352,9 @@ detach_controlling_tty(void) static pid_t setsid(void) { - setpgid(0, 0); + if (setpgid(0, 0) < 0) + return -1: + detach_controlling_tty(); return 0; @@ -374,7 +376,8 @@ daemonize(void) _exit(0); /* Create a new session. */ - setsid(); + if (setsid() < 0) + fatal("cannot set session ID"); pid = fork(); if (pid < 0) |