spclose()
Andreas Ericsson
ae at op5.se
Sat Jan 8 21:36:30 CET 2005
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 andreas.ericsson at op5.se
OP5 AB www.op5.se
Lead Developer
-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
More information about the Developers
mailing list