[PATCH] D53000: [Support] Ignore SIGPIPE, don't error on EPIPE from raw_fd_ostream

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 8 14:35:19 PDT 2018


nickdesaulniers created this revision.
nickdesaulniers added a reviewer: jfb.
Herald added subscribers: llvm-commits, kristina.

Fixes warnings from writing to closed readers.  This can be seen
commonly from piping into head, or redirecting stdout/sterr to tee or
split.

If the reader closes early, assume they don't care about additional
output; there's nothing we could handle from the driver anyways.

Fixes PR25349.


Repository:
  rL LLVM

https://reviews.llvm.org/D53000

Files:
  lib/Support/Unix/Signals.inc
  lib/Support/raw_ostream.cpp


Index: lib/Support/raw_ostream.cpp
===================================================================
--- lib/Support/raw_ostream.cpp
+++ lib/Support/raw_ostream.cpp
@@ -709,6 +709,9 @@
           )
         continue;
 
+      if (errno == EPIPE)
+        break;
+
       // Otherwise it's a non-recoverable error. Note it and quit.
       error_detected(std::error_code(errno, std::generic_category()));
       break;
Index: lib/Support/Unix/Signals.inc
===================================================================
--- lib/Support/Unix/Signals.inc
+++ lib/Support/Unix/Signals.inc
@@ -203,7 +203,7 @@
 // if there is, it's not our direct responsibility. For whatever reason, our
 // continued execution is no longer desirable.
 static const int IntSigs[] = {
-  SIGHUP, SIGINT, SIGPIPE, SIGTERM, SIGUSR1, SIGUSR2
+  SIGHUP, SIGINT, SIGTERM, SIGUSR1, SIGUSR2
 };
 
 // Signals that represent that we have a bug, and our prompt termination has
@@ -297,6 +297,7 @@
     registerHandler(S);
   for (auto S : KillSigs)
     registerHandler(S);
+  signal(SIGPIPE, SIG_IGN);
 }
 
 static void UnregisterHandlers() {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53000.168710.patch
Type: text/x-patch
Size: 1118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181008/3c2cd505/attachment.bin>


More information about the llvm-commits mailing list