summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-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()
993 return -2; 993 return -2;
994 } 994 }
995 // Redirect standard files to /dev/null 995 // Redirect standard files to /dev/null
996 freopen("/dev/null", "r", stdin); 996 if (!freopen("/dev/null", "r", stdin)) {
997 freopen("/dev/null", "w", stdout); 997 logmsg(LOG_ERR, "ERROR: redirection of stdin failed.\n");
998 freopen("/dev/null", "w", stderr); 998 }
999 if (!freopen("/dev/null", "w", stdout)) {
1000 logmsg(LOG_ERR, "ERROR: redirection of stdout failed.\n");
1001 }
1002 if (!freopen("/dev/null", "w", stderr)) {
1003 logmsg(LOG_ERR, "ERROR: redirection of stderr failed.\n");
1004 }
999 1005
1000 return 0; 1006 return 0;
1001} 1007}
@@ -1320,6 +1326,7 @@ int main(int argc, char **argv)
1320 if (children[i] != NULL) { 1326 if (children[i] != NULL) {
1321 pthread_join(children[i]->thread, NULL); 1327 pthread_join(children[i]->thread, NULL);
1322 free(children[i]); 1328 free(children[i]);
1329 children[i] = NULL;
1323 } 1330 }
1324 } 1331 }
1325 1332