This is seen in bison and possibly other programs.  Bison will
incorrectly receive SIGPIPE and terminate because close_stream() is
picking up a rogue EPIPE in errno.  Before fclose(), clearerr(stdout)
needs to be called so that the errors it will check for are for the
immediate call of close_stream().
---
 lib/closeout.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/closeout.c b/lib/closeout.c
index 311faf4..36895a2 100644
--- a/lib/closeout.c
+++ b/lib/closeout.c
@@ -106,6 +106,8 @@ close_stdout_set_ignore_EPIPE (bool ignore)
 void
 close_stdout (void)
 {
+  clearerr (stdout);
+
   if (close_stream (stdout) != 0
       && !(ignore_EPIPE && errno == EPIPE))
     {
-- 
1.9.0

Reply via email to