<div dir="ltr">Confirming that:<div><br></div><div>signal (SIGCHLD, SIG_DFL);<div><br></div><div>works.</div><div><br></div><div>Thank you, Rich!<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Best Regards,<br>Peter</div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Nov 8, 2018 at 5:07 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Thu, Nov 08, 2018 at 04:51:31PM +0200, Peter Dimitrov wrote:<br>
> Here are strace outputs per process.<br>
> <br>
> strace_output.22076 is the plugin's pid. (A little before forking)<br>
<br>
Ah ha.<br>
<br>
Close reading of the waitpid(2) man page says:<br>
<br>
       ECHILD (for  waitpid() or waitid()) The process specified by pid (wait‐<br>
              pid()) or idtype and id (waitid()) does not exist or  is  not  a<br>
              child  of  the  calling process.  (This can happen for one's own<br>
              child if the action for SIGCHLD is set to SIG_IGN.  See also the<br>
              Linux Notes section about threads.)<br>
<br>
I'm going to guess that collectd is leaking the signal handler setting<br>
into the child process instead of resetting it.  This is a bug in<br>
collectd.<br>
<br>
It's surprisingly hard to correctly fork a process in Unix.  Here's<br>
what libvirt does, which is the most comprehensive code that I know<br>
of.  It involves resetting multiple things before running the child:<br>
<br>
  <a href="https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/util/vircommand.c;h=de937f6f9aa91abb518eac98bfac9dcf37e1f5df;hb=HEAD#l280" rel="noreferrer" target="_blank">https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/util/vircommand.c;h=de937f6f9aa91abb518eac98bfac9dcf37e1f5df;hb=HEAD#l280</a><br>
<br>
While you're getting the collectd bug fixed, the easiest workaround is<br>
probably to add:<br>
<br>
  signal (SIGCHLD, SIG_DFL);<br>
<br>
in your code.<br>
<br>
Rich.<br>
<br>
-- <br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
virt-top is 'top' for virtual machines.  Tiny program with many<br>
powerful monitoring features, net stats, disk stats, logging, etc.<br>
<a href="http://people.redhat.com/~rjones/virt-top" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones/virt-top</a><br>
</blockquote></div>