bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9089: pipe failure with cat and head of coreutils 6.12


From: Pádraig Brady
Subject: bug#9089: pipe failure with cat and head of coreutils 6.12
Date: Fri, 15 Jul 2011 14:26:54 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 15/07/11 14:03, Eric Blake wrote:
> On 07/15/2011 05:30 AM, Philipp Thomas wrote:
>> I'm trying to track down a bug in cat of coreutils 6.12. Doing 
>>
>> cat /var/log/Xorg.0.log | head -n70
>>
>> under ksh consistently fails with 'cat: write error: Connection reset by
>> peer'.  It does not fail when run under bash and it does not fail in current
>> coreutils .  It seems that ksh implementing pipes by socketpair(2) is the
>> reason for this failure.
> 
> And that behavior of ksh is probably a violation of POSIX:
> http://austingroupbugs.net/view.php?id=205
> 
> There, the Austin Group discussion around the issue was that since
> socketpair() creates observable differences from pipe(), including your
> example (where socket disconnect behaves differently than EPIPE errors),
> and many programs are not expecting these differences, that ksh should
> probably be fixed to use pipe() like everyone else.

Note the reason ksh does this, is to allow commands
to efficiently inspect the input, rather than reading byte by byte.
This is related to the recent `stdbuf -i0` discussions.

> Conversely, if cat already has any special handling for EPIPE, then we
> should probably do that same handling for socket disconnects.

Probably

>> Does somebody have a hint how to track this down? When trying to use strace
>> it won't fail

Note it seems to be timing dependent whether ECONNRESET or EPIPE is returned.
To get ECONNRESET reliably I need to:

ksh -c "strace yes | (sleep 1; head -n10) > /dev/null"

cheers,
Pádraig.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]