On 01/20/2012 10:59 AM, Jaroslav Škarvada wrote:
Proposed fix: exit on the first EPIPE error in case the SIGPIPE is blocked.

http://bugzilla.redhat.com/show_bug.cgi?id=741452
---
  src/main.c |    3 ++-
  1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/main.c b/src/main.c
index 51135ad..4ca326b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,6 +30,7 @@
  #include<wctype.h>
  #include<fcntl.h>
  #include<stdio.h>
+#include<unistd.h>
  #include "system.h"

  #include "argmatch.h"
@@ -881,7 +882,7 @@ prline (char const *beg, char const *lim, int sep)
      fwrite (beg, 1, lim - beg, stdout);

    if (ferror (stdout))
-    error (0, errno, _("writing output"));
+    error ((errno == EPIPE) ? EXIT_FAILURE : 0, errno, _("writing output"));

    lastout = lim;


I think this should be EXIT_TROUBLE (aka exit status 2). Jim/Paul, what do you think?

Paolo

Reply via email to