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. Cheers, Michael. -- Michael Schroeder m...@suse.de SUSE LINUX Products GmbH, GF Jeff Hawn, HRB 16746 AG Nuernberg main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);} _______________________________________________ Rpm-maint mailing list Rpm-maint@lists.rpm.org http://lists.rpm.org/mailman/listinfo/rpm-maint