avoid a segfault, if ulimit is set to unlimited

This commit is contained in:
nafets 2014-11-19 22:34:23 +01:00 committed by Sven Nierlein
parent 054bfc9922
commit 6bb5e1db52

View file

@ -116,6 +116,14 @@ cmd_init (void)
}
#endif
/* if maxfd is unnaturally high, we force it to a lower value
* ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause
* a segfault when following calloc is called ... ) */
if ( maxfd > 2048 ) {
maxfd = 2048;
}
if (!_cmd_pids)
_cmd_pids = calloc (maxfd, sizeof (pid_t));
}