From c70a761d6492e2af63c0fc1ddcb55fa625839908 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 10 Nov 2012 23:41:53 +0100 Subject: util.pposix: Prevent FDs 0, 1 and 2 from being assigned to connections --- util-src/pposix.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util-src/pposix.c b/util-src/pposix.c index 191e276e..05303d99 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -89,6 +89,10 @@ static int lc_daemonize(lua_State *L) close(0); close(1); close(2); + /* Make sure accidental use of FDs 0, 1, 2 don't cause weirdness */ + open("/dev/null", O_RDONLY); + open("/dev/null", O_WRONLY); + open("/dev/null", O_WRONLY); /* Final fork, use it wisely */ if(fork()) -- cgit v1.2.3