Close all FD's instead of just 0,1,2 on startup
Changed the startup in the main function to loop through all file descriptors from getrlimit(RLIMIT_NOFILE) down to 0, and close them all to make sure none are left opened by the parent process.
This commit is contained in:
parent
27a087ac3d
commit
6fc342929c
|
@ -351,9 +351,10 @@ char *argv[];
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
||||||
close(0);
|
for (int i = getrlimit(RLIMIT_NOFILE); i >= 0; --i) {
|
||||||
close(1);
|
close(i);
|
||||||
close(2);
|
}
|
||||||
|
|
||||||
if (setsid() < 0) {
|
if (setsid() < 0) {
|
||||||
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
|
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
|
||||||
syslog(LOG_ERR, "Failed to set new session ID at startup.");
|
syslog(LOG_ERR, "Failed to set new session ID at startup.");
|
||||||
|
|
Loading…
Reference in a new issue