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: Eric Blake
Subject: bug#9089: pipe failure with cat and head of coreutils 6.12
Date: Fri, 15 Jul 2011 07:03:00 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.11

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.

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

> Does somebody have a hint how to track this down? When trying to use strace
> it won't fail and I don't know how to get this to run under gdb.

gdb --args ksh -c 'cat /var/log/Xorg.0.log | head -n70'

then use 'set follow-fork-mode child' at the appropriate point to get
gdb to move over to the cat subprocess.  Except that by default, you
won't have any time to put any breakpoints in cat after exec(), unless
you also recompile cat to inject a sleep() at the top of main() to give
you some reaction time to get gdb to put useful breaks into the cat
subprocess.

Painful, yes, but at least it would give you the same setup as what you
are trying to debug.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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