short read/write and error code

David Xu listlog2011 at gmail.com
Wed Aug 1 23:31:56 UTC 2012


On 2012/8/2 2:58, Bruce Evans wrote:
> On Wed, 1 Aug 2012, Konstantin Belousov wrote:
>
>> As I said, patch behaviour in regard of SIGPIPE is just wrong.
>
> It is too simple.

The pipe code already reset error code zero if the writer have written 
all bytes
to pipe buffer, it does not return EPIPE even if reader closed the pipe, so
SIGPIPE is not sent in the case.
The SIGPIPE is only generated for short write, this is an intention, it 
is for
applications which takes no notice of short write, such an application 
does not
check return value from write(), when kernel generates SIGPIPE, the 
default action
is to kill the application, if application setup a sigaction for 
SIGPIPE, this implies
that application knows short write. So the patch is correct when it sees 
EPIPE code.

Regards,
David Xu



More information about the freebsd-arch mailing list