service_start(): Redirect service output to /dev/null by default

This patch prevents output of stderr/stdout from services to leak to the
console.  Use the 'log' keyword to service/run/task stanza to redirect
output to syslog.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-10-15 21:39:58 +02:00
parent b02f241e5e
commit 2b173e831f
+10
View File
@@ -265,7 +265,17 @@ static int service_start(svc_t *svc)
dup2(fd, STDERR_FILENO);
close(fd);
}
} else {
FILE *fp;
fp = fopen("/dev/null", "w");
if (fp) {
dup2(fileno(fp), STDOUT_FILENO);
dup2(fileno(fp), STDERR_FILENO);
}
fclose(fp);
}
logger_err:
sig_unblock();