aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2014-04-03 22:14:18 +0000
committerXin LI <delphij@FreeBSD.org>2014-04-03 22:14:18 +0000
commit37c55e8558a48cc4c248246c1075bfb0bc0bf88a (patch)
tree0918c40bce1647ed0f095d3ad4c7c89ef13dcd20
parentee83e77448cf42bf36f5b2dd99a1e865a154d8c3 (diff)
downloadsrc-37c55e8558a48cc4c248246c1075bfb0bc0bf88a.tar.gz
src-37c55e8558a48cc4c248246c1075bfb0bc0bf88a.zip
Detach from controlling session of parent. This is similar
to what is done in daemon(3), which we can not use directly in this context. Reviewed by: pjd MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=264089
-rw-r--r--sbin/casperd/zygote.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sbin/casperd/zygote.c b/sbin/casperd/zygote.c
index fdc7ca115ff5..be3d9e5eee4c 100644
--- a/sbin/casperd/zygote.c
+++ b/sbin/casperd/zygote.c
@@ -63,6 +63,9 @@ stdnull(void)
if (fd == -1)
errx(1, "Unable to open %s", _PATH_DEVNULL);
+ if (setsid() == -1)
+ errx(1, "Unable to detach from session");
+
if (dup2(fd, STDIN_FILENO) == -1)
errx(1, "Unable to cover stdin");
if (dup2(fd, STDOUT_FILENO) == -1)