This avoids a potential crash if too many subprocesses (Bug#24325).
* src/process.c [HAVE_SETRLIMIT]: Include <sys/resource.h>.
(init_process_emacs): If ulimit -n is greater than FD_SETSIZE,
set it to FD_SETSIZE.
#include <netinet/in.h>
#include <arpa/inet.h>
+#ifdef HAVE_SETRLIMIT
+# include <sys/resource.h>
+#endif
+
/* Are local (unix) sockets supported? */
#if defined (HAVE_SYS_UN_H)
#if !defined (AF_LOCAL) && defined (AF_UNIX)
catch_child_signal ();
}
+#ifdef HAVE_SETRLIMIT
+ /* Don't allocate more than FD_SETSIZE file descriptors. */
+ struct rlimit rlim;
+ if (getrlimit (RLIMIT_NOFILE, &rlim) == 0 && FD_SETSIZE < rlim.rlim_cur)
+ {
+ rlim.rlim_cur = FD_SETSIZE;
+ setrlimit (RLIMIT_NOFILE, &rlim);
+ }
+#endif
+
FD_ZERO (&input_wait_mask);
FD_ZERO (&non_keyboard_wait_mask);
FD_ZERO (&non_process_wait_mask);