Commit d4a5b4fe authored by ale's avatar ale

close file descriptors after forking logger

parent 92df484d
......@@ -212,10 +212,15 @@ void setup_syslog() {
fprintf(stderr, "Error: could not spawn logger: %s\n", strerror(errno));
return;
} else if (pid == 0) {
int i;
char *logger_args[] = {
"logger", "-p", "daemon.info", "-t", tag, NULL,
};
/* Put the pipe on stdin, close all other fds. */
dup2(pipefd[0], 0);
for (i = 1; i < 1024; i++) {
close(i);
}
r = execvp(logger_args[0], logger_args);
if (r < 0) {
fprintf(stderr, "Error: logger: %s\n", strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment