From: Richard W.M. Jones Date: Thu, 23 Feb 2012 17:06:32 +0000 (+0000) Subject: daemon: On fork, open stdin/stdout/stderr on /dev/null. X-Git-Tag: 0.0.3~2 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=083f42734bf06c6a752e3a93e519c6250a04dd96;p=whenjobs.git daemon: On fork, open stdin/stdout/stderr on /dev/null. --- diff --git a/daemon/whenjobsd.ml b/daemon/whenjobsd.ml index 164a7e2..1efde6c 100644 --- a/daemon/whenjobsd.ml +++ b/daemon/whenjobsd.ml @@ -104,10 +104,13 @@ Options: (* chdir / so we don't prevent filesystems from being unmounted. *) chdir "/"; - (* Close file descriptors. *) + (* Close file descriptors, replace with /dev/null. *) close stdin; close stdout; close stderr; + ignore (openfile "/dev/null" [O_RDONLY] 0); + ignore (openfile "/dev/null" [O_WRONLY] 0); + ignore (openfile "/dev/null" [O_WRONLY] 0); (* Create a new session. *) ignore (setsid ());