summaryrefslogtreecommitdiff
path: root/src/supervision
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-19 12:26:39 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-19 12:26:39 +0000
commite28fe5908a91d8795ca9923d64eeed7d3e898434 (patch)
tree0048b802c550857b9553695d988dd79e5c5c5eb5 /src/supervision
parent9e993c95b20db3cb6709d07b37de7cb7a5b4b70a (diff)
downloads6-e28fe5908a91d8795ca9923d64eeed7d3e898434.tar.xz
setpgrp() when nosetsid contains "setpgrp" (asked by Buck Evans)
Diffstat (limited to 'src/supervision')
-rw-r--r--src/supervision/s6-supervise.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c
index 80b7959..fa2cff9 100644
--- a/src/supervision/s6-supervise.c
+++ b/src/supervision/s6-supervise.c
@@ -6,6 +6,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <strings.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
@@ -188,18 +189,26 @@ static void killy (void)
static void failcoe (int fd)
{
- register int e = errno ;
+ int e = errno ;
fd_write(fd, "", 1) ;
errno = e ;
}
static int maybesetsid (void)
{
- if (access("nosetsid", F_OK) < 0)
+ char buf[8] = "-------" ;
+ ssize_t r = openreadnclose("nosetsid", buf, 8) ;
+ if (r < 0)
{
if (errno != ENOENT) return 0 ;
setsid() ;
}
+ else
+ {
+ if (r == 8 && buf[7] == '\n') buf[--r] = 0 ;
+ if (r == 7 && !strncasecmp(buf, "setpgrp", 7))
+ setpgrp() ;
+ }
return 1 ;
}