summaryrefslogtreecommitdiff
path: root/utils/start-stop-daemon.c
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2014-09-09 14:47:39 +0200
committerGuillem Jover <guillem@debian.org>2014-10-06 00:40:43 +0200
commit877057869d5ae7cc3a0c7911ab905275b41d1d09 (patch)
treea7ea0e31cd6ffae2c94e251b680dae2de59298d8 /utils/start-stop-daemon.c
parent1fab3f69a9c8991c3431a0cca3e49446f6a161e2 (diff)
downloaddpkg-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/start-stop-daemon.c')
-rw-r--r--utils/start-stop-daemon.c7
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)