Raise the file descriptor limit to the maximum

This commit is contained in:
Přemysl Eric Janouch 2014-09-19 09:20:14 +02:00
parent 4662e84995
commit 6f1bc52711
1 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,7 @@
#include <dirent.h> #include <dirent.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/resource.h>
#include <curses.h> #include <curses.h>
#include <term.h> #include <term.h>
@ -1894,6 +1895,17 @@ main (int argc, char *argv[])
setup_signal_handlers (); setup_signal_handlers ();
// Set the maximum count of file descriptorts to the hard limit
struct rlimit limit;
if (getrlimit (RLIMIT_NOFILE, &limit))
print_warning ("%s: %s", "getrlimit failed", strerror (errno));
else
{
limit.rlim_cur = limit.rlim_max;
if (setrlimit (RLIMIT_NOFILE, &limit))
print_warning ("%s: %s", "setrlimit failed", strerror (errno));
}
init_terminal (); init_terminal ();
atexit (free_terminal); atexit (free_terminal);