diff options
Diffstat (limited to 'src/supervision')
-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 ; } |