[RFC] fork error in check.c

Andreas Ericsson ae at op5.se
Mon Apr 21 16:07:19 CEST 2008


Hendrik BŠäcker wrote:
> Hi List,
> 
> since memory eating ePN is enabled as default in Nagios 3 some users ran 
> into fork error cause of memory limits, but no one told them.
> 
> They only see some log messages like: "Warning: The check of service xx 
> could not be performed due to a fork() error."
> 
> I've spent some time on the code and would suggest attached patch.
> 
> Since the "fork_error" is only filled once in 
> "run_async_service_check()", I guess it should be ok to move the logging 
> earlier up to the fork error, so we could use strerror() to determine 
> why the error occurs.
> But I am not sure if the part:
> 
> if (fork_error == TRUE)
>    return ERROR;
> 
> has to stand at the last lines of the function or if we are able to 
> return quiet after the fork error.
> 
> It would be nice to see s.th. like sterror() in checks.c so that the 
> users out there could imagine why an fork error occurs.
> 

The one bad thing I can think of wrt this is that errno is not always
thread-specific. Iow, one thread can see the fork() error and decide
to report it. After the error but before the reporting line, another
thread could have gotten some other, non-fatal, error which nevertheless
set the errno variable to something which a fork() error can never get
(most of them, actually, since fork() can usually only ever result in
EAGAIN or ENOMEM). Showing "Permission denied", "Device or resource busy",
"No such device" or "Structure needs cleaning" definitely wouldn't help
the user all that much. We can't check for it though, and the proposed
solution will make a difference for the majority of the users, so go for
it but be aware of the possible issues with it.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list