From 083f42734bf06c6a752e3a93e519c6250a04dd96 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 23 Feb 2012 17:06:32 +0000 Subject: [PATCH] daemon: On fork, open stdin/stdout/stderr on /dev/null. --- daemon/whenjobsd.ml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 ()); -- 1.8.3.1