summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-01-13 00:04:13 +0000
committerLaurent Bercot <ska@appnovation.com>2022-01-13 00:04:13 +0000
commit0840786b5826d81b447e4cd4292f0615b17a15ae (patch)
treeaefb4437479e1a69f254b33d54f7e384a1764105
parentfafa34059864fb8985d66243270c1e72609d4762 (diff)
downloads6-linux-init-0840786b5826d81b447e4cd4292f0615b17a15ae.tar.xz
Get the supervision tree rid of any control terminal
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--src/init/s6-linux-init.c4
-rw-r--r--src/shutdown/s6-linux-init-shutdownd.c8
2 files changed, 6 insertions, 6 deletions
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]) ;
diff --git a/src/shutdown/s6-linux-init-shutdownd.c b/src/shutdown/s6-linux-init-shutdownd.c
index d9fba7e..ddf5804 100644
--- a/src/shutdown/s6-linux-init-shutdownd.c
+++ b/src/shutdown/s6-linux-init-shutdownd.c
@@ -306,11 +306,11 @@ int main (int argc, char const *const *argv)
strerr_warnwu2sys("exec ", stage4_argv[0]) ;
}
- fdr = open_read(SHUTDOWND_FIFO) ;
- if (fdr == -1 || coe(fdr) == -1)
+ fdr = openc_read(SHUTDOWND_FIFO) ;
+ if (fdr == -1)
strerr_diefu3sys(111, "open ", SHUTDOWND_FIFO, " for reading") ;
- fdw = open_write(SHUTDOWND_FIFO) ;
- if (fdw == -1 || coe(fdw) == -1)
+ fdw = openc_write(SHUTDOWND_FIFO) ;
+ if (fdw == -1)
strerr_diefu3sys(111, "open ", SHUTDOWND_FIFO, " for writing") ;
if (!sig_altignore(SIGPIPE))
strerr_diefu1sys(111, "ignore SIGPIPE") ;