[Nagiosplug-devel] check_dns: DNS WARNING - nslookup returned error status
Andreas Ericsson
ae at op5.se
Fri Sep 2 05:16:30 CEST 2005
Dag Wieers wrote:
> On Fri, 2 Sep 2005, sean finney wrote:
>
>
>>now, a question about this patch...
>>
>>the code in question:
>>
>>==
>> 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() */
>> }
>>
>> if (WIFEXITED (status))
>> return (WEXITSTATUS (status)); /* return child's termination status */
>>
>>> return (1);
>>
>>==
>>
>>does this remove the check for the child's exit status?
>
>
> The patch is not mine, but I think you are correct. It probably should be
> something like:
>
> while (waitpid (pid, &status, 0) < 0) {
>
> switch(errno) {
> case ECHILD: break; /* Child has already exited */
This is a never-ending loop. If we get ECHILD once, we'll get it every time.
> case EINTR: break; /* Interrupted function call */
> case default: return 1;
This is bad, because all commands that exit successfully will return 1
and thus issue a warning.
> }
>
> }
>
Below this point is never reached.
> if (WIFEXITED (status))
> return (WEXITSTATUS (status)); /* return child's termination status */
>
> return 1;
>
I've revamped the runcmd thingie and it's been running stable for a
couple of months, so it's ready for implementation. CVS commit access or
a couple of hours with Sean and it'll be available for download in a
jiffy. A snapshot is already available at http://oss.op5.se/nagios/
although that snapshot has a bug in check_load.c when neither
/proc/loadavg or getloadavg() is available (which is inherited from the
official distro, but still).
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
More information about the Devel
mailing list