From f1bce25d0c74ab6bced83c8aa9a2b8ef58d63441 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Sat, 15 May 2010 03:17:19 -0400 Subject: [PATCH] Fix freopen properly --- src/dmaster.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/dmaster.c b/src/dmaster.c index 2835a43..bc8ea02 100644 --- a/src/dmaster.c +++ b/src/dmaster.c @@ -103,9 +103,12 @@ static void setup_daemon(void) { 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"); } }