diff --git a/timeoutd.c b/timeoutd.c index c3cf310..2de0596 100644 --- a/timeoutd.c +++ b/timeoutd.c @@ -351,9 +351,10 @@ char *argv[]; if (pid > 0) exit(0); - close(0); - close(1); - close(2); + for (int i = getrlimit(RLIMIT_NOFILE); i >= 0; --i) { + close(i); + } + if (setsid() < 0) { openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); syslog(LOG_ERR, "Failed to set new session ID at startup.");