bug-gnulib
[Top][All Lists]
Advanced

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

Darwin vs. cat


From: Eric Blake
Subject: Darwin vs. cat
Date: Tue, 03 Mar 2009 06:29:12 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.19) Gecko/20081209 Thunderbird/2.0.0.19 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

When running test-closein.sh, I'm getting spurious output on Darwin:

cat: standard output: Bad file descriptor
PASS: test-closein.sh

$ cat --version | head -n 1
cat (GNU coreutils) 7.1
$ uname -v
Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007;
root:xnu-792.24.17~1/RELEASE_PPC

I ran ktrace/kdump, and it looks like the problem occurs any time a pipe
is created, but the reader exits without reading anything prior to the
writer attempting to write.  For example:

$ echo hi > foo
$ cat foo | :
cat: standard output: Bad file descriptor
$ cat foo | { :; sleep 0.01; }
$

It seems like the Darwin kernel is failing to give SIGPIPE/EPIPE failures,
and instead gives EBADF when the read end of the pipe is gone.  Is this
anything that coreutils should try to work around?  Meanwhile, I'm
checking this in to gnulib to silence the testsuite (we don't care about
messages from cat, but from the test-closein executable).

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmtMKgACgkQ84KuGfSFAYCa/QCfSHoC6Ie6pkwCo8GMnLv2iLfc
GBoAn0DDSzuZucXbmFkWUyr2Ope+ZLva
=Fi99
-----END PGP SIGNATURE-----
>From 5416f5b033beaf4254aea4c2a38d28f0ab6f2e6d Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Tue, 3 Mar 2009 06:15:08 -0700
Subject: [PATCH] test-closein: silence test under Darwin

* tests/test-closein.sh: Ignore stderr from cat, since we don't
care if it dies from EPIPE or EBADF.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog             |    6 ++++++
 tests/test-closein.sh |    6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d109e90..f4841af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-03  Eric Blake  <address@hidden>
+
+       test-closein: silence test under Darwin
+       * tests/test-closein.sh: Ignore stderr from cat, since we don't
+       care if it dies from EPIPE or EBADF.
+
 2009-03-03  Bruno Haible  <address@hidden>

        * doc/gnulib.texi: Include visibility.texi and ld-version-script.texi
diff --git a/tests/test-closein.sh b/tests/test-closein.sh
index 4f57511..a75929a 100755
--- a/tests/test-closein.sh
+++ b/tests/test-closein.sh
@@ -16,10 +16,10 @@ cmp ${p}out1.tmp ${p}in.tmp || exit 1
 (./test-closein${EXEEXT} consume; cat) < ${p}in.tmp > ${p}out2.tmp || exit 1
 cmp ${p}out2.tmp ${p}xout.tmp || exit 1

-# Test for lack of error on pipe
-cat ${p}in.tmp | ./test-closein${EXEEXT} || exit 1
+# Test for lack of error on pipe.  Ignore any EPIPE failures from cat.
+cat ${p}in.tmp 2>/dev/null | ./test-closein${EXEEXT} || exit 1

-cat ${p}in.tmp | ./test-closein${EXEEXT} consume || exit 1
+cat ${p}in.tmp 2>/dev/null | ./test-closein${EXEEXT} consume || exit 1

 # Test for lack of error when nothing is read
 ./test-closein${EXEEXT} </dev/null || exit 1
-- 
1.6.1.2


reply via email to

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