Skip to content

Commit b75c448

Browse files
author
git apple-llvm automerger
committed
Merge commit '48f68ac91784' from apple/stable/20190619 into swift/master
2 parents 65fe35c + 48f68ac commit b75c448

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lldb/tools/driver/Driver.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,25 @@ main(int argc, char const *argv[])
858858
}
859859
SBHostOS::ThreadCreated("<lldb.driver.main-thread>");
860860

861+
// Install llvm's signal handlers up front to prevent lldb's handlers from
862+
// being ignored. This is (hopefully) a stopgap workaround.
863+
//
864+
// When lldb invokes an llvm API that installs signal handlers (e.g.
865+
// llvm::sys::RemoveFileOnSignal, possibly via a compiler embedded within
866+
// lldb), lldb's signal handlers are overriden if llvm is installing its
867+
// handlers for the first time.
868+
//
869+
// To work around llvm's behavior, force it to install its handlers up front,
870+
// and *then* install lldb's handlers. In practice this is used to prevent
871+
// lldb test processes from exiting due to IO_ERR when SIGPIPE is received.
872+
//
873+
// Note that when llvm installs its handlers, it 1) records the old handlers
874+
// it replaces and 2) re-installs the old handlers when its new handler is
875+
// invoked. That means that a signal not explicitly handled by lldb can fall
876+
// back to being handled by llvm's handler the first time it is received,
877+
// and then by the default handler the second time it is received.
878+
llvm::sys::AddSignalHandler([](void *) -> void {}, nullptr);
879+
861880
signal(SIGINT, sigint_handler);
862881
#if !defined(_MSC_VER)
863882
signal(SIGPIPE, SIG_IGN);

0 commit comments

Comments
 (0)