diff options
author | Nikias Bassen | 2009-05-04 18:23:52 +0200 |
---|---|---|
committer | Nikias Bassen | 2009-05-04 18:23:52 +0200 |
commit | e4ee9af3ee1c7dbd25d5ca183cc35fa6e48469eb (patch) | |
tree | 82c58c398f720b1e62d1105ab16e18b467742113 | |
parent | 7364e09f6849076c710ac9ce52a5d5fd2445e19c (diff) | |
download | usbmuxd-e4ee9af3ee1c7dbd25d5ca183cc35fa6e48469eb.tar.gz usbmuxd-e4ee9af3ee1c7dbd25d5ca183cc35fa6e48469eb.tar.bz2 |
null children[i] pointers after freeing them and check for errors when
calling freopen (prevents compiler warnings).
-rw-r--r-- | src/main.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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; } } |