bug-grep
[Top][All Lists]
Advanced

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

Re: [PATCH] main.c: exit on the first EPIPE error


From: Paolo Bonzini
Subject: Re: [PATCH] main.c: exit on the first EPIPE error
Date: Fri, 20 Jan 2012 15:40:55 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0

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

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