Rewrite log_trace to be thread-safe and some cleanups
This commit is contained in:
9
rmps.c
9
rmps.c
@@ -99,7 +99,6 @@ static void daemonize(const char *rundir)
|
||||
}
|
||||
/* Fork*/
|
||||
pid = fork();
|
||||
/*printf("fork() = %d\n", pid);*/
|
||||
if (pid < 0) {
|
||||
/* Could not fork */
|
||||
log_trace(ERROR, "Failed to fork the parent process. Exiting!");
|
||||
@@ -118,10 +117,10 @@ static void daemonize(const char *rundir)
|
||||
log_trace(ERROR, "Failed to create a process group. Exiting!");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* Close all file descriptors because we fork */
|
||||
for (i = getdtablesize(); i >= 0; --i)
|
||||
close(i);
|
||||
|
||||
/* Close all file descriptors because we fork */
|
||||
close(0); /* stdin */
|
||||
close(1); /* stdout */
|
||||
close(2); /* stderr */
|
||||
/* Route I/O connections */
|
||||
/* Open STDIN */
|
||||
i = open("/dev/null", O_RDWR);
|
||||
|
||||
Reference in New Issue
Block a user