diff options
author | nafets <fis.stefan@gmail.com> | 2014-11-19 22:34:23 +0100 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2014-11-28 15:21:23 +0100 |
commit | 6bb5e1db525f44a7ab40e9391244dbe65daa08cc (patch) | |
tree | eb2f16e6694fb572b61e265a8ee8e8afa946cea9 /lib | |
parent | 054bfc992239e531ab6c9bb7e3a5d777f3c8a009 (diff) | |
download | monitoring-plugins-6bb5e1db525f44a7ab40e9391244dbe65daa08cc.tar.gz |
avoid a segfault, if ulimit is set to unlimited
Diffstat (limited to 'lib')
-rw-r--r-- | lib/utils_cmd.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c index 9e214bd4..e41a9821 100644 --- a/lib/utils_cmd.c +++ b/lib/utils_cmd.c | |||
@@ -116,6 +116,14 @@ cmd_init (void) | |||
116 | } | 116 | } |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | /* if maxfd is unnaturally high, we force it to a lower value | ||
120 | * ( e.g. on SunOS, when ulimit is set to unlimited: 2147483647 this would cause | ||
121 | * a segfault when following calloc is called ... ) */ | ||
122 | |||
123 | if ( maxfd > 2048 ) { | ||
124 | maxfd = 2048; | ||
125 | } | ||
126 | |||
119 | if (!_cmd_pids) | 127 | if (!_cmd_pids) |
120 | _cmd_pids = calloc (maxfd, sizeof (pid_t)); | 128 | _cmd_pids = calloc (maxfd, sizeof (pid_t)); |
121 | } | 129 | } |