소스 검색

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)
abrist 11 년 전
부모
커밋
d077d64e54
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      plugins-root/pst3.c

+ 3 - 1
plugins-root/pst3.c

@@ -139,8 +139,10 @@ try_again:
     if((ps_fd = open(ps_name, O_RDONLY)) == -1)
       continue;
 
-    if((as_fd = open(as_name, O_RDONLY)) == -1)
+    if((as_fd = open(as_name, O_RDONLY)) == -1) {
+      close(ps_fd);
       continue;
+    }
 
     if(read(ps_fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) {
       int err = errno;