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
This commit is contained in:
delphij 2014-04-03 22:14:18 +00:00
parent 2c5d789700
commit 727357321c

View File

@ -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)