Re: [Nagios-devel] spclose()

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

Re: [Nagios-devel] spclose()

Post by Guest »

Ben wrote:
> I'm looking over the recommended function spclose() in the nagios-plugins
> package, and am confused about the output. Basically, it's supposed to
> return the output of the program I am trying to run, which is nice.... but
> on errors, it's supposed to return 1. This seems a rather unfortunate
> choice, because now I can't tell if spclose had an error or if my program
> really did return 1.
>
> Am I looking at this wrong?
>

You're absolutely right (although it's supposed to return the exit value
of the program, and not the output).

The pclose(3) man-page states that it should return -1 if it encounters
any errors. 1 can obviously be a proper return value, so using it to
detect in-function errors points to rather shoddy code (it should also
set errno to ECHILD in case it can't obtain the child status).

It's simple enough to fix, so I'm not submitting a patch. Plugin
developers should be able to handle it anyway.

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked