[llvm] r344372 - [Support] exit with custom return code for SIGPIPE
Nick Desaulniers via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 12 10:22:07 PDT 2018
Author: nickdesaulniers
Date: Fri Oct 12 10:22:07 2018
New Revision: 344372
URL: http://llvm.org/viewvc/llvm-project?rev=344372&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Support/Unix/Signals.inc
Modified: llvm/trunk/lib/Support/Unix/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Signals.inc?rev=344372&r1=344371&r2=344372&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Signals.inc (original)
+++ llvm/trunk/lib/Support/Unix/Signals.inc Fri Oct 12 10:22:07 2018
@@ -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;
}
More information about the llvm-commits
mailing list