Blame pr-2393-1.patch

Andy Lutomirski f3c942
commit 890f35cbcb28440c7e6c74055a77e3474c39fc3e
Andy Lutomirski f3c942
Author: Andy Lutomirski <luto@kernel.org>
Andy Lutomirski f3c942
Date:   Tue Sep 15 18:24:11 2015 -0700
Andy Lutomirski f3c942
Andy Lutomirski f3c942
    Don't complain if do_builtin_io fails due to EPIPE
Andy Lutomirski f3c942
    
Andy Lutomirski f3c942
    If stdio is dead due to EPIPE, there's no great reason to spew a stack dump.
Andy Lutomirski f3c942
    
Andy Lutomirski f3c942
    This will still write an error to stderr if stdout dies.  This might be
Andy Lutomirski f3c942
    undesirable, but changing that should be considered separately.
Andy Lutomirski f3c942
Andy Lutomirski f3c942
diff --git a/src/exec.cpp b/src/exec.cpp
Andy Lutomirski f3c942
index 39385b06a432..d7ff483bda3b 100644
Andy Lutomirski f3c942
--- a/src/exec.cpp
Andy Lutomirski f3c942
+++ b/src/exec.cpp
Andy Lutomirski f3c942
@@ -1161,7 +1161,7 @@ void exec_job(parser_t &parser, job_t *j)
Andy Lutomirski f3c942
                             const std::string outbuff = wcs2string(out);
Andy Lutomirski f3c942
                             const std::string errbuff = wcs2string(err);
Andy Lutomirski f3c942
                             bool builtin_io_done = do_builtin_io(outbuff.data(), outbuff.size(), errbuff.data(), errbuff.size());
Andy Lutomirski f3c942
-                            if (! builtin_io_done)
Andy Lutomirski f3c942
+                            if (! builtin_io_done && errno != EPIPE)
Andy Lutomirski f3c942
                             {
Andy Lutomirski f3c942
                                 show_stackframe();
Andy Lutomirski f3c942
                             }
Andy Lutomirski f3c942
diff --git a/src/postfork.cpp b/src/postfork.cpp
Andy Lutomirski f3c942
index 1eb958ad9f0d..29cf850ca3d6 100644
Andy Lutomirski f3c942
--- a/src/postfork.cpp
Andy Lutomirski f3c942
+++ b/src/postfork.cpp
Andy Lutomirski f3c942
@@ -569,12 +569,13 @@ bool do_builtin_io(const char *out, size_t outlen, const char *err, size_t errle
Andy Lutomirski f3c942
     bool success = true;
Andy Lutomirski f3c942
     if (out && outlen)
Andy Lutomirski f3c942
     {
Andy Lutomirski f3c942
-
Andy Lutomirski f3c942
         if (write_loop(STDOUT_FILENO, out, outlen) < 0)
Andy Lutomirski f3c942
         {
Andy Lutomirski f3c942
+            int e = errno;
Andy Lutomirski f3c942
             debug_safe(0, "Error while writing to stdout");
Andy Lutomirski f3c942
             safe_perror("write_loop");
Andy Lutomirski f3c942
             success = false;
Andy Lutomirski f3c942
+            errno = e;
Andy Lutomirski f3c942
         }
Andy Lutomirski f3c942
     }
Andy Lutomirski f3c942