diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-19 12:26:39 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2017-02-19 12:26:39 +0000 |
commit | e28fe5908a91d8795ca9923d64eeed7d3e898434 (patch) | |
tree | 0048b802c550857b9553695d988dd79e5c5c5eb5 /src/supervision/s6-supervise.c | |
parent | 9e993c95b20db3cb6709d07b37de7cb7a5b4b70a (diff) | |
download | s6-e28fe5908a91d8795ca9923d64eeed7d3e898434.tar.gz s6-e28fe5908a91d8795ca9923d64eeed7d3e898434.tar.xz s6-e28fe5908a91d8795ca9923d64eeed7d3e898434.zip |
setpgrp() when nosetsid contains "setpgrp" (asked by Buck Evans)
Diffstat (limited to 'src/supervision/s6-supervise.c')
-rw-r--r-- | src/supervision/s6-supervise.c | 13 |
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 ; } |