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 [email protected] +1-801-349-2682 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
