Code

SIGALRM could be received before child_process is created (Jason Crawford)
[nagiosplug.git] / plugins / popen.c
index f6810691460c8e2fa26ec33359533f6a140c7b5f..5da12a02fb46a22d7af22bc7fabe9adddc41e7ce 100644 (file)
@@ -270,12 +270,16 @@ popen_timeout_alarm_handler (int signo)
 {
        int fh;
        if (signo == SIGALRM) {
-               fh=fileno (child_process);
-               if(fh >= 0){
-                       kill (childpid[fh], SIGKILL);
-               }
-               printf (_("CRITICAL - Plugin timed out after %d seconds\n"),
+               if (child_process != NULL) {
+                       fh=fileno (child_process);
+                       if(fh >= 0){
+                               kill (childpid[fh], SIGKILL);
+                       }
+                       printf (_("CRITICAL - Plugin timed out after %d seconds\n"),
                                                timeout_interval);
+               } else {
+                       printf (_("CRITICAL - popen timeout received, but no child process\n"));
+               }
                exit (STATE_CRITICAL);
        }
 }