util.pposix: Prevent FDs 0, 1 and 2 from being assigned to connections
authorKim Alvefur <zash@zash.se>
Sat, 10 Nov 2012 22:41:53 +0000 (23:41 +0100)
committerKim Alvefur <zash@zash.se>
Sat, 10 Nov 2012 22:41:53 +0000 (23:41 +0100)
util-src/pposix.c

index 191e276ee1bc4576603feae2451924547bf5606d..05303d99ae574a2e1ab990f64d06d206e19fd11a 100644 (file)
@@ -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())