lib/process: Don't abort stdout reads on EINTR
authorJeremy Kerr <jk@ozlabs.org>
Thu, 20 Feb 2014 01:22:58 +0000 (09:22 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 20 Feb 2014 02:11:52 +0000 (10:11 +0800)
commitffb84fc1bf1d138d1ac1bb8ece0b7d625f288d97
treefcb5a469816b4b929686f343735a2b2942cf7cf1
parent0b3bfb90a292ceba33b649681876ec1ed50c8447
lib/process: Don't abort stdout reads on EINTR

If our read() of the process stdout pipe fails with EINTR (eg, if we
receive a SIGCHLD because the process exited), then
process_read_stdout_once will return a non-zero exit code, and we'll
abort any further stdout collection.

Instead, we should check for EINTR, and allow the reads to continue.

This change normalises the return value from process_read_stdout_once to
return positive on success, negative on failure, and zero on competion.
We use a positive return value for the non-error EINTR case.

Also, add a pb_log if the read fails for non-EINTR reasons.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/process/process.c
test/lib/Makefile.am
test/lib/test-process-stdout-eintr.c [new file with mode: 0644]