Fix getrlimit call in main

This commit is contained in:
Petar Kapris 2020-12-16 23:15:55 +01:00
parent 16e428b36f
commit d1e322d12d

View file

@ -38,6 +38,7 @@
#include <grp.h> #include <grp.h>
#include <sys/syslog.h> #include <sys/syslog.h>
#include <time.h> #include <time.h>
#include <sys/resource.h>
#include <ctype.h> #include <ctype.h>
#include <termios.h> #include <termios.h>
#include <fcntl.h> #include <fcntl.h>
@ -351,7 +352,14 @@ char *argv[];
if (pid > 0) if (pid > 0)
exit(0); exit(0);
for (int i = getrlimit(RLIMIT_NOFILE); i >= 0; --i) { struct rlimit r;
if (getrlimit(RLIMIT_NOFILE, &r) == -1) {
openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON);
syslog(LOG_ERR, "Coudln't get file resource limit.");
closelog();
exit(1);
}
for (int i = r.rlim_cur; i >= 0; --i) {
close(i); close(i);
} }