[Nagiosplug-devel] check_dns: DNS WARNING - nslookup returned error status

Ton Voon tonvoon at mac.com
Mon Sep 5 03:51:11 CEST 2005


On 2 Sep 2005, at 14:34, Peter Pramberger wrote:

> sean finney schrieb:
>
>> so what, redhat is now defaulting to having that set?  i think i  
>> see a
>> way around this, but i'm not sure:
>>
>> - set a signal handler for SIGCHLD
>> - when SIGCHLD is thrown, we do exactly the opposite from the  
>> above, and
>>   *not* call any wait functions.
>>
>> i think that should leave the child as a zombie, for our later  
>> call to
>> waitpid.
>>
>
> Maybe somehow like this? It's only a rough draft and looks very  
> ugly, but it
> seems to work.
>
>
> Regards,
> Peter
>
> --- nagios-plugins-1.4.1/plugins/popen.c.orig    2005-09-02  
> 15:06:55.929161410 +0200
> +++ nagios-plugins-1.4.1/plugins/popen.c    2005-09-02  
> 15:26:13.632795170 +0200
> @@ -31,6 +31,7 @@
>  FILE *spopen (const char *);
>  int spclose (FILE *);
>  RETSIGTYPE popen_timeout_alarm_handler (int);
> +RETSIGTYPE popen_sigchld_handler (int);
>
>  #include <stdarg.h>                            /* ANSI C header  
> file */
>  #include <fcntl.h>
> @@ -66,6 +67,7 @@
>  /*int *childerr = NULL;*//* ptr to array allocated at run-time */
>  /*extern pid_t *childpid = NULL; *//* ptr to array allocated at  
> run-time */
>  static int maxfd;                                /* from our  
> open_max(), {Prog openmax} */
> +static volatile int childtermd = 0;
>
>  FILE *
>  spopen (const char *cmdstring)
> @@ -86,6 +88,9 @@
>      limit.rlim_cur = 0;
>      setrlimit (RLIMIT_CORE, &limit);
>  #endif
> +    if (signal (SIGCHLD, popen_sigchld_handler) == SIG_ERR) {
> +        usage4 (_("Cannot catch SIGCHLD"));
> +    }
>
>      env[0] = strdup("LC_ALL=C");
>      env[1] = '\0';
> @@ -220,11 +225,10 @@
>      if (fclose (fp) == EOF)
>          return (1);
>
> +    while (!childtermd);                                /* wait  
> until SIGCHLD */
> +
>      while (waitpid (pid, &status, 0) < 0)
>      {
> -        if (errno == ECHILD)
> -            return (0);                            /* Child has  
> already exited */
> -
>          if (errno != EINTR)
>              return (1);                            /* error other  
> than EINTR from waitpid() */
>      }
> @@ -260,6 +264,13 @@
>      }
>  }
>
> +void
> +popen_sigchld_handler (int signo)
> +{
> +    if (signo == SIGCHLD)
> +        childtermd = 1;
> +}
> +
>
>  int
>  open_max (void)
>

Peter,

Thanks, this patch seems to work fine. I want to see what Red Hat  
have to say about the issue first (since Sascha will raise it with  
them). If they haven't come back within a week, we can put this patch  
in.

Ton





More information about the Devel mailing list