From e4ee9af3ee1c7dbd25d5ca183cc35fa6e48469eb Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Mon, 4 May 2009 18:23:52 +0200 Subject: null children[i] pointers after freeing them and check for errors when calling freopen (prevents compiler warnings). --- src/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index e7292cc..b4b5283 100644 --- a/src/main.c +++ b/src/main.c @@ -993,9 +993,15 @@ static int daemonize() return -2; } // Redirect standard files to /dev/null - freopen("/dev/null", "r", stdin); - freopen("/dev/null", "w", stdout); - freopen("/dev/null", "w", stderr); + if (!freopen("/dev/null", "r", stdin)) { + logmsg(LOG_ERR, "ERROR: redirection of stdin failed.\n"); + } + if (!freopen("/dev/null", "w", stdout)) { + logmsg(LOG_ERR, "ERROR: redirection of stdout failed.\n"); + } + if (!freopen("/dev/null", "w", stderr)) { + logmsg(LOG_ERR, "ERROR: redirection of stderr failed.\n"); + } return 0; } @@ -1320,6 +1326,7 @@ int main(int argc, char **argv) if (children[i] != NULL) { pthread_join(children[i]->thread, NULL); free(children[i]); + children[i] = NULL; } } -- cgit v1.1-32-gdbae