Back to index

nagios-plugins  1.4.16
Functions | Variables
popen.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

FILE * spopen (const char *)
int spclose (FILE *)
RETSIGTYPE popen_timeout_alarm_handler (int)

Variables

unsigned int timeout_interval
pid_t * childpid = NULL
int * child_stderr_array = NULL
FILE * child_process = NULL
FILE * child_stderr = NULL

Function Documentation

RETSIGTYPE popen_timeout_alarm_handler ( int  )

Definition at line 295 of file popen.c.

{
       int fh;
       if (signo == SIGALRM) {
              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 ("%s\n", _("CRITICAL - popen timeout received, but no child process"));
              }
              exit (STATE_CRITICAL);
       }
}
int spclose ( FILE *  )

Definition at line 246 of file popen.c.

{
       int fd, status;
       pid_t pid;

       if (childpid == NULL)
              return (1);                                                    /* popen() has never been called */

       fd = fileno (fp);
       if ((pid = childpid[fd]) == 0)
              return (1);                                                    /* fp wasn't opened by popen() */

       childpid[fd] = 0;
       if (fclose (fp) == EOF)
              return (1);

#ifdef REDHAT_SPOPEN_ERROR
       while (!childtermd);                                                  /* wait until SIGCHLD */
#endif

       while (waitpid (pid, &status, 0) < 0)
              if (errno != EINTR)
                     return (1);                                             /* error other than EINTR from waitpid() */

       if (WIFEXITED (status))
              return (WEXITSTATUS (status));     /* return child's termination status */

       return (1);
}
FILE* spopen ( const char *  )

Variable Documentation

Definition at line 13 of file popen.h.

FILE* child_stderr = NULL

Definition at line 14 of file popen.h.

Definition at line 12 of file popen.h.

pid_t* childpid = NULL

Definition at line 11 of file popen.h.

unsigned int timeout_interval

Definition at line 35 of file check_hltherm.c.