[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] fatal: print to "standard output" failed (Broken pipe)
From: |
Aharon Robbins |
Subject: |
Re: [bug-gawk] fatal: print to "standard output" failed (Broken pipe) |
Date: |
Thu, 31 Oct 2013 23:10:04 +0200 |
User-agent: |
Heirloom mailx 12.5 6/20/10 |
Hi Andy.
> This is perhaps a stupid question, but it seems as if this patch
> may result in the program's not exiting due to the write error.
> I can understand that it may not be desirable to print the error
> message, but is it clear that the program should not exit?
I think you're right. Nice catch. How about this, instead?
Arnold
------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 3798a5f..df252b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-31 Arnold D. Robbins <address@hidden>
+
+ * builtin.c (efwrite): If write error to stdout is EPIPE,
+ die silently. Thanks to Hermann Peifer for helping find this.
+
2013-10-22 Arnold D. Robbins <address@hidden>
Revise error messages when writing to standard output or standard
diff --git a/builtin.c b/builtin.c
index 9258ea6..1f044f3 100644
--- a/builtin.c
+++ b/builtin.c
@@ -125,6 +125,11 @@ efwrite(const void *ptr,
return;
wrerror:
+ /* die silently on EPIPE to stdout */
+ if (fp == stdout && errno == EPIPE)
+ gawk_exit(EXIT_FATAL);
+
+ /* otherwise die verbosely */
fatal(_("%s to \"%s\" failed (%s)"), from,
rp ? rp->value : _("standard output"),
errno ? strerror(errno) : _("reason unknown"));