From 4fa2b1d3dd9890687d3b590295e26542d4c8179b Mon Sep 17 00:00:00 2001 From: Kat Magic Date: Wed, 16 Jun 2010 01:46:00 -0400 Subject: [PATCH] Remove a warning about ignoring the return value of freopen(). --- src/shallot.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/shallot.c b/src/shallot.c index 4fbf9b1..8622b5f 100644 --- a/src/shallot.c +++ b/src/shallot.c @@ -232,8 +232,10 @@ int main(int argc, char *argv[]) { // onions are fun, here we go umask(077); // remove permissions to be safe // redirect output - freopen(file, "w", stdout); - freopen(file, "w", stderr); + if ( + (freopen(file, "w", stdout) == NULL) || + (freopen(file, "w", stderr) == NULL) + ) error(X_FILE_OPEN_ERR); } if(daemon && (getppid() != 1)) { // daemonize if we should @@ -254,7 +256,9 @@ int main(int argc, char *argv[]) { // onions are fun, here we go if(chdir("/") < 0) // cd to root error(X_DAEMON_FAILED); - freopen("/dev/null", "r", stdin); // block input + // block input + if (freopen("/dev/null", "r", stdin) == NULL) + error(X_FILE_OPEN_ERR); // ignore certain signals signal(SIGCHLD, SIG_IGN); -- 2.11.4.GIT