summaryrefslogtreecommitdiffstats
path: root/plugins-root/pst3.c
diff options
context:
space:
mode:
authorabrist <abrist@nagios.com>2015-07-28 19:20:38 (GMT)
committerJan Wagner <waja@cyconet.org>2015-10-13 09:39:17 (GMT)
commitc097642e52072e84287e9a6aea894585f32387ff (patch)
treeda09571443139bb1f27b22648b772e710703fbf6 /plugins-root/pst3.c
parentf729ee3b4db11634634652b282384fa2007a2364 (diff)
downloadmonitoring-plugins-c097642e52072e84287e9a6aea894585f32387ff.tar.gz
Fix for unclosed filehandle in pst3 on Solaris
On Solaris, check_procs uses pst3 instead of /bin/ps (see http://monitoring-plugins.org/doc/faq/ps-on-solaris.html for background). There's a small bug in pst3 which causes it to NOT report some processes that are at the end of the process table, at least on very busy systems (we noticed this on a CoolThreads T5240 with load averages up to 90). The bug is that a filehandle is not properly closed. Thanks to jwinkle01 for finding and patching the bug. (Closes #1203)
Diffstat (limited to 'plugins-root/pst3.c')
-rw-r--r--plugins-root/pst3.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/plugins-root/pst3.c b/plugins-root/pst3.c
index ee9d108..c3589f0 100644
--- a/plugins-root/pst3.c
+++ b/plugins-root/pst3.c
@@ -139,8 +139,10 @@ try_again:
139 if((ps_fd = open(ps_name, O_RDONLY)) == -1) 139 if((ps_fd = open(ps_name, O_RDONLY)) == -1)
140 continue; 140 continue;
141 141
142 if((as_fd = open(as_name, O_RDONLY)) == -1) 142 if((as_fd = open(as_name, O_RDONLY)) == -1) {
143 close(ps_fd);
143 continue; 144 continue;
145 }
144 146
145 if(read(ps_fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) { 147 if(read(ps_fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) {
146 int err = errno; 148 int err = errno;