summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/InitLLVM.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2019-11-14 14:30:56 -0800
committerVedant Kumar <vsk@apple.com>2019-11-18 10:27:27 -0800
commit4624e83ce7b124545b55e45ba13f2d900ed65654 (patch)
tree740c1cb7f4666d5cd5f1895184e0a3d4699f1004 /llvm/lib/Support/InitLLVM.cpp
parent5a4a05d776d3adacad344b2b5e15cf594c906bce (diff)
downloadbcm5719-llvm-4624e83ce7b124545b55e45ba13f2d900ed65654.tar.gz
bcm5719-llvm-4624e83ce7b124545b55e45ba13f2d900ed65654.zip
[Signal] Allow llvm clients to opt into one-shot SIGPIPE handling
Allow clients of the llvm library to opt-in to one-shot SIGPIPE handling, instead of forcing them to undo llvm's SIGPIPE handler registration (which is brittle). The current behavior is preserved for all llvm-derived tools (except lldb) by means of a default-`true` flag in the InitLLVM constructor. This prevents "IO error" crashes in long-lived processes (lldb is the motivating example) which both a) load llvm as a dynamic library and b) *really* need to ignore SIGPIPE. As llvm signal handlers can be installed when calling into libclang (say, via RemoveFileOnSignal), thereby overriding a previous SIG_IGN for SIGPIPE, there is no clean way to opt-out of "exit-on-SIGPIPE" in the current model. Differential Revision: https://reviews.llvm.org/D70277
Diffstat (limited to 'llvm/lib/Support/InitLLVM.cpp')
-rw-r--r--llvm/lib/Support/InitLLVM.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Support/InitLLVM.cpp b/llvm/lib/Support/InitLLVM.cpp
index 0d7d7fcc8cb..bb9b569d2de 100644
--- a/llvm/lib/Support/InitLLVM.cpp
+++ b/llvm/lib/Support/InitLLVM.cpp
@@ -21,7 +21,11 @@
using namespace llvm;
using namespace llvm::sys;
-InitLLVM::InitLLVM(int &Argc, const char **&Argv) : StackPrinter(Argc, Argv) {
+InitLLVM::InitLLVM(int &Argc, const char **&Argv,
+ bool InstallPipeSignalExitHandler)
+ : StackPrinter(Argc, Argv) {
+ if (InstallPipeSignalExitHandler)
+ sys::SetOneShotPipeSignalFunction(sys::DefaultOneShotPipeSignalHandler);
sys::PrintStackTraceOnErrorSignal(Argv[0]);
install_out_of_memory_new_handler();
OpenPOWER on IntegriCloud