summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2018-10-12 17:22:07 +0000
committerNick Desaulniers <ndesaulniers@google.com>2018-10-12 17:22:07 +0000
commit727891c9182aabd39cef9998ab7be365cb5ab19b (patch)
tree4f87d723a1860ec8b252ca442f1498e3ca6357c0 /llvm/lib/Support
parentaa30268539a9e958b149b0583de02eeb7e10e5e8 (diff)
downloadbcm5719-llvm-727891c9182aabd39cef9998ab7be365cb5ab19b.tar.gz
bcm5719-llvm-727891c9182aabd39cef9998ab7be365cb5ab19b.zip
[Support] exit with custom return code for SIGPIPE
Summary: We tell the user to file a bug report on LLVM right now, and SIGPIPE isn't LLVM's fault so our error message is wrong. Allows frontends to detect SIGPIPE from writing to closed readers. This can be seen commonly from piping into head, tee, or split. Fixes PR25349, rdar://problem/14285346, b/77310947 Reviewers: jfb Reviewed By: jfb Subscribers: majnemer, kristina, llvm-commits, thakis, srhines Differential Revision: https://reviews.llvm.org/D53000 llvm-svn: 344372
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/Unix/Signals.inc5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc
index de26695d64e..ad88d5e9690 100644
--- a/llvm/lib/Support/Unix/Signals.inc
+++ b/llvm/lib/Support/Unix/Signals.inc
@@ -47,6 +47,7 @@
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <string>
+#include <sysexits.h>
#ifdef HAVE_BACKTRACE
# include BACKTRACE_HEADER // For backtrace().
#endif
@@ -334,6 +335,10 @@ static RETSIGTYPE SignalHandler(int Sig) {
if (auto OldInterruptFunction = InterruptFunction.exchange(nullptr))
return OldInterruptFunction();
+ // Send a special return code that drivers can check for, from sysexits.h.
+ if (Sig == SIGPIPE)
+ exit(EX_IOERR);
+
raise(Sig); // Execute the default handler.
return;
}
OpenPOWER on IntegriCloud