commit e28fe5908a91d8795ca9923d64eeed7d3e898434
parent 9e993c95b20db3cb6709d07b37de7cb7a5b4b70a
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Sun, 19 Feb 2017 12:26:39 +0000
setpgrp() when nosetsid contains "setpgrp" (asked by Buck Evans)
Diffstat:
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git 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 ;
}