Diff

util-src/pposix.c @ 5176:7d0a8b255a37

util.pposix: Prevent FDs 0, 1 and 2 from being assigned to connections
author Kim Alvefur <zash@zash.se>
date Sat, 10 Nov 2012 23:41:53 +0100
parent 5068:14d4fc5859b9
child 5359:43517e649c53
line wrap: on
line diff
--- a/util-src/pposix.c	Sat Nov 10 23:39:22 2012 +0100
+++ b/util-src/pposix.c	Sat Nov 10 23:41:53 2012 +0100
@@ -89,6 +89,10 @@
 	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())