run-command: detect finished children by closed pipe rather than waitpid
commitd5a66a9477156e0ce82bd1bbdf6254c5cfae87c9
authorStefan Beller <sbeller@google.com>
Fri, 6 Nov 2015 23:48:57 +0000 (6 15:48 -0800)
committerJohannes Sixt <j6t@kdbg.org>
Tue, 10 Nov 2015 09:13:33 +0000 (10 10:13 +0100)
tree404a968330a1cccdf9ea6314e6b7834d9fe84a18
parentb55431ddc21306e9afd949e1088be6f3f265ccd4
run-command: detect finished children by closed pipe rather than waitpid

Detect if a child stopped working by checking if their stderr pipe
was closed instead of checking their state with waitpid.
As waitpid is not fully working in Windows, this is an approach which
allows for better cross platform operation. (It's less code, too)

Previously we did not close the read pipe of finished children, which we
do now.

The old way missed some messages on an early abort. We just killed the
children and did not bother to look what was left over. With this approach
we'd send a signal to the children and wait for them to close the pipe to
have all the messages (including possible "killed by signal 15" messages).

To have the test suite passing as before, we allow for real graceful
abortion now. In case the user wishes to abort parallel execution
the user needs to provide either the signal used to kill all children
or the children are let run until they finish normally.

Signed-off-by: Stefan Beller <sbeller@google.com>
run-command.c
run-command.h
submodule.c
test-run-command.c