mirror of
https://github.com/troglobit/finit.git
synced 2026-10-02 05:52:48 +07:00
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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user