aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2021-01-14 10:30:24 -0500
committerRuss Cox <rsc@swtch.com>2021-01-14 10:30:24 -0500
commit52b599a63c488d3a80bb9f5dd97bad0b10103c54 (patch)
tree468de2036ba5873e032e810a07b71f2c9571d26a
parent3ccd61629b641613bcccbc51125330efab9c89a7 (diff)
downloadplan9port-52b599a63c488d3a80bb9f5dd97bad0b10103c54.tar.gz
plan9port-52b599a63c488d3a80bb9f5dd97bad0b10103c54.tar.bz2
plan9port-52b599a63c488d3a80bb9f5dd97bad0b10103c54.zip
libthread: call setpgrp in programs that will background
This fixes the 'run stats from rc; exit rc; stats dies' problem. It's unclear whether this is the right fix or whether rc should be starting all its interactive commands in their own process groups. But at least it does fix stats dying.
-rw-r--r--src/libthread/daemonize.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libthread/daemonize.c b/src/libthread/daemonize.c
index f994ffe1..29929068 100644
--- a/src/libthread/daemonize.c
+++ b/src/libthread/daemonize.c
@@ -101,6 +101,13 @@ _threadsetupdaemonize(void)
sigpid = 1;
+ /*
+ * We've been told this program is likely to background itself.
+ * Put it in its own process group so that we don't get a SIGHUP
+ * when the parent exits.
+ */
+ setpgrp();
+
if(pipe(p) < 0)
sysfatal("passer pipe: %r");