]> git.itanic.dy.fi Git - rrdd/commit
process: Fix bug with child processes stuck forever when parent segfaults
authorTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 27 Jun 2012 15:18:19 +0000 (18:18 +0300)
committerTimo Kokkonen <timo.t.kokkonen@iki.fi>
Wed, 27 Jun 2012 18:36:45 +0000 (21:36 +0300)
commitbe6ca816aa5a6e0edfaac2c6970b27ba991e8d6d
treef7bfa53a46f07f67b1dbfb0575136a2065ed352c
parent3ec2bfb421e4b5bb3d24643f23057ad689807904
process: Fix bug with child processes stuck forever when parent segfaults

After a fork() the child needs to close the unused end of the process
control pipes. Failing to do so will prevent EOF and EPIPE signals
from being delivered correctly back to the child when the parent
closes its end of the pipe.

Furthermore, the code's assumption about the behaviour of the pipe
with one writer and multiple readers was wrong. When there are
multiple readers, only one will be woken up and the rest will be left
blocking the read in case there was nothing left to read. If read
returns zero, that means EOF, eg. the job control parent has closed
its end of the pipe.

These fixes applied there should be no more problem with a lot of
child processes stuck in waiting the parent to give them a permission
to go. They will either fail with SIGPIPE when they request the
permission to run or they will read zero bytes from the pipe and
continue executing instantly.

Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
process.c