From 37c55e8558a48cc4c248246c1075bfb0bc0bf88a Mon Sep 17 00:00:00 2001 From: Xin LI Date: Thu, 3 Apr 2014 22:14:18 +0000 Subject: [PATCH] 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 --- sbin/casperd/zygote.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sbin/casperd/zygote.c b/sbin/casperd/zygote.c index fdc7ca115ff..be3d9e5eee4 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)