munin-monitoring / munin

Main repository for munin master / node / plugins
http://munin-monitoring.org
Other
1.98k stars 471 forks source link

waitpid can return -1 on success #755

Open mgeisler opened 7 years ago

mgeisler commented 7 years ago

Related to #749, I noticed that an error is logged by RRDs_graph even if the rrdtool command works fine when run by hand. The error I see is

2016-11-19 14:56:09 [error][025233]: Error generating image: 72057594037927935

"Luckily", RRDs_graph continues execution in this case and still sends the image to the client.

I believe this might be because the return value of waitpid is interpreted in the wrong way. According to http://perldoc.perl.org/functions/waitpid.html the return value is -1 if the child process is not found. 72057594037927935 is 0xffffffffffffff which looks like a -1 to me. I guess rrdtool simply returned too fast on my machine.

sumpfralle commented 6 years ago

I am not too deeply into the topic, but I have the following understanding:

In our code we use the following:

my $child_exit_status = ($? >> 8);

I have the feeling, that in general, this is the proper handling.

But I do not understand, why $? equals -1 at this moment. The documentation for $? does not mention negative values:

Does someone have an idea, how -1 could end up in $?? I have the vague feeling, it is specific to the environment, we created.