From 0840786b5826d81b447e4cd4292f0615b17a15ae Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 13 Jan 2022 00:04:13 +0000 Subject: Get the supervision tree rid of any control terminal Signed-off-by: Laurent Bercot --- src/init/s6-linux-init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/init/s6-linux-init.c') diff --git a/src/init/s6-linux-init.c b/src/init/s6-linux-init.c index bb24a52..e88bccf 100644 --- a/src/init/s6-linux-init.c +++ b/src/init/s6-linux-init.c @@ -99,7 +99,7 @@ static inline void run_stage2 (char const *basedir, char const **argv, unsigned for (unsigned int i = 0 ; i < argc ; i++) childargv[i+2] = argv[i] ; childargv[argc + 2] = 0 ; - setsid() ; + if (!inns) setsid() ; if (nologger) { close(notifpipe[1]) ; @@ -178,7 +178,6 @@ int main (int argc, char const **argv, char const *const *envp) else if (hasconsole) allwrite(1, BANNER, sizeof(BANNER) - 1) ; if (chdir("/") == -1) strerr_diefu1sys(111, "chdir to /") ; umask(mask) ; - setpgid(0, 0) ; close(0) ; if (slashdev) @@ -273,6 +272,7 @@ int main (int argc, char const **argv, char const *const *envp) pid = fork() ; if (pid == -1) strerr_diefu1sys(111, "fork") ; if (!pid) run_stage2(basedir, argv, argc, newenvp, !!path, envmodifs.s, envmodifs.len, initdefault) ; + setsid() ; if (nologger) { close(notifpipe[0]) ; -- cgit v1.2.3