Rewrite log_trace to be thread-safe and some cleanups

This commit is contained in:
2016-08-08 22:31:29 +03:00
parent e9f3673bfd
commit dcd58d8281
8 changed files with 127 additions and 74 deletions

9
rmps.c
View File

@@ -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);