Properly reopen stdin,stdout and stderr in daemon.

pull/31/head
weetmuts 2019-08-13 20:46:50 +02:00
rodzic b176e89a0c
commit abaefdf829
1 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -409,6 +409,15 @@ void startDaemon(string pid_file)
close(STDOUT_FILENO);
close(STDERR_FILENO);
if (open("/dev/null", O_RDONLY) == -1) {
error("Failed to reopen stdin while daemonising (errno=%d)",errno);
}
if (open("/dev/null", O_WRONLY) == -1) {
error("Failed to reopen stdout while daemonising (errno=%d)",errno);
}
if (open("/dev/null", O_RDWR) == -1) {
error("Failed to reopen stderr while daemonising (errno=%d)",errno);
}
startUsingConfigFiles("", true);
}