summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2009-05-04 18:23:52 +0200
committerGravatar Nikias Bassen2009-05-04 18:23:52 +0200
commite4ee9af3ee1c7dbd25d5ca183cc35fa6e48469eb (patch)
tree82c58c398f720b1e62d1105ab16e18b467742113 /src/main.c
parent7364e09f6849076c710ac9ce52a5d5fd2445e19c (diff)
downloadusbmuxd-e4ee9af3ee1c7dbd25d5ca183cc35fa6e48469eb.tar.gz
usbmuxd-e4ee9af3ee1c7dbd25d5ca183cc35fa6e48469eb.tar.bz2
null children[i] pointers after freeing them and check for errors when
calling freopen (prevents compiler warnings).
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c13
1 files 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;
}
}