bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 1/2] pread: new module


From: Jim Meyering
Subject: Re: [PATCH 1/2] pread: new module
Date: Thu, 26 Nov 2009 08:52:14 +0100

Bruno Haible wrote:
> Jim Meyering wrote:
>>  fail=0;
>> -test-pread || fail=1
>> +echo abc | test-pread || fail=1
>
> When I execute it step by step, on Linux (openSUSE 11.0, bash 3.2.1), I get an
> error message on stderr:
>
> $ bash
> $ : ${srcdir=.}
> $ . $srcdir/init.sh --set-path=.
> $ fail=0;
> $ echo abc | test-pread || fail=1
> bash: echo: write error: Broken pipe

That is because something[*] in your environment has arranged to ignore
SIGPIPE.  Normally, it is *not* ignored, the writer is silently killed,
and thus, the writer has no chance to notice the write failure.

[*] the code that ignore's SIGPIPE for you may be in your
system's display-manager, or login-manager's code.
Could this be the same dbus problem I tracked down two years ago?
  http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/11203/focus=11902
  http://bugs.freedesktop.org/show_bug.cgi?id=13318

...

> When I replace the 'echo abc' with a call to coreutils' echo program, the
> error message goes away.
>
> When I write
>   echo abc 2>/dev/null | test-pread
> the error message also goes away.

Thanks for the report.
I've avoided the diagnostic by changing the script
not to write anything to the pipe:

>From 2fbe772172eb8f078031d68030e3b85c5bd8d57b Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 26 Nov 2009 08:51:11 +0100
Subject: [PATCH] test-pread.sh: avoid diagnostics for those who ignore SIGPIPE

* tests/test-pread.sh: Write no data into the pipe, because
test-pread actually reads none.  This avoids a diagnostic,
"bash: echo: write error: Broken pipe", that arises in the unusual
event something is ignoring SIGPIPE, and might be interpreted
as some sort of failure.  Reported by Bruno Haible.
---
 ChangeLog           |    9 +++++++++
 tests/test-pread.sh |    4 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2ec9906..bcb4340 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2009-11-26  Jim Meyering  <address@hidden>
+
+       test-pread.sh: avoid diagnostics for those who ignore SIGPIPE
+       * tests/test-pread.sh: Write no data into the pipe, because
+       test-pread actually reads none.  This avoids a diagnostic,
+       "bash: echo: write error: Broken pipe", that arises in the unusual
+       event something is ignoring SIGPIPE, and might be interpreted
+       as some sort of failure.  Reported by Bruno Haible.
+
 2009-11-25  Jim Meyering  <address@hidden>

        test-pread: cover failure with ESPIPE and EINVAL
diff --git a/tests/test-pread.sh b/tests/test-pread.sh
index 5ab88eb..d7824ad 100755
--- a/tests/test-pread.sh
+++ b/tests/test-pread.sh
@@ -2,7 +2,7 @@
 : ${srcdir=.}
 . $srcdir/init.sh --set-path=.

-fail=0;
-echo abc | test-pread || fail=1
+fail=0
+: | test-pread || fail=1

 Exit $fail
--
1.6.6.rc0.54.gb073b




reply via email to

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