summaryrefslogtreecommitdiff
path: root/libc/unistd/daemon.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/unistd/daemon.c')
-rw-r--r--libc/unistd/daemon.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c
index bfad7a363..d4c2e0448 100644
--- a/libc/unistd/daemon.c
+++ b/libc/unistd/daemon.c
@@ -48,6 +48,11 @@ int daemon( int nochdir, int noclose )
if (setsid() == -1)
return(-1);
+ /* Make certain we are not a session leader, or else we
+ * might reacquire a controlling terminal */
+ if (fork())
+ _exit(0);
+
if (!nochdir)
chdir("/");