Fix freopen properly
authorMichael Spang <mspang@csclub.uwaterloo.ca>
Sat, 15 May 2010 07:17:19 +0000 (03:17 -0400)
committerMichael Spang <mspang@csclub.uwaterloo.ca>
Thu, 14 Oct 2010 18:00:07 +0000 (14:00 -0400)
src/dmaster.c

index 2835a43..bc8ea02 100644 (file)
@@ -103,9 +103,12 @@ static void setup_daemon(void) {
 
         setup_pidfile();
 
 
         setup_pidfile();
 
-        stdin = freopen("/dev/null", "r", stdin);
-        stdout = freopen("/dev/null", "w", stdout);
-        stderr = freopen("/dev/null", "w", stderr);
+        if (!freopen("/dev/null", "r", stdin))
+            fatalpe("freopen");
+        if (!freopen("/dev/null", "w", stdout))
+            fatalpe("freopen");
+        if (!freopen("/dev/null", "w", stderr))
+            fatalpe("freopen");
     }
 }
 
     }
 }