[Rpm-maint] Sigpipe handling in build/rpmfc.c
mls at suse.de
Tue Jun 7 07:14:25 UTC 2011
On Tue, Jun 07, 2011 at 09:35:38AM +0300, Panu Matilainen wrote:
> >IMHO aborting the read when a SIGCHLD occurs is wrong, as the
> >pipe may still contain unread data (and data is only read in
> >sizeof(buf)-1 chunks). Wouldn't it make more sense to simply
> >ignore SIGCHLD and read until an EOF is returned, i.e. the
> >read returns zero bytes?
> SIGCHLD needs to be caught to avoid hanging in the select if the child
> exists without flushing its stdin,
Why? You're reading from the child, so you'll get an EOF when
the child exits, i.e. if there are no processes left that have the
write side of the pipe open. It can't hang.
> but you're probably right the reading
> side could (in some rather rare conditions) miss some final bits from
> the child output. Hum, I guess SIGCHLD should only abort the loop if
> there are unwritten bytes left. Need to scratch head + consume coffee
> some more...
Just read until you get an EOF (which always happens if the child
exists), and then return an error if writeBytesLeft is not zero.
Michael Schroeder mls at suse.de
SUSE LINUX Products GmbH, GF Jeff Hawn, HRB 16746 AG Nuernberg
More information about the Rpm-maint