Skip to content

Commit d0bd3fc

Browse files
committed
Revert "Disable exit-on-SIGPIPE in lldb"
This reverts commit 32ce14e. In post-commit review, Pavel pointed out that there's a simpler way to ignore SIGPIPE in lldb that doesn't rely on llvm's handlers.
1 parent 23b7836 commit d0bd3fc

File tree

6 files changed

+1
-92
lines changed

6 files changed

+1
-92
lines changed

lldb/tools/driver/Driver.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -853,16 +853,6 @@ int main(int argc, char const *argv[])
853853
signal(SIGCONT, sigcont_handler);
854854
#endif
855855

856-
// Occasionally, during test teardown, LLDB writes to a closed pipe.
857-
// Sometimes the communication is inherently unreliable, so LLDB tries to
858-
// avoid being killed due to SIGPIPE. However, LLVM's default SIGPIPE behavior
859-
// is to exit with IO_ERR. Opt LLDB out of that.
860-
//
861-
// We don't disable LLVM's signal handling entirely because we still want
862-
// pretty stack traces, and file cleanup (for when, say, the clang embedded
863-
// in LLDB leaves behind temporary objects).
864-
llvm::sys::SetPipeSignalFunction(nullptr);
865-
866856
int exit_code = 0;
867857
// Create a scope for driver so that the driver object will destroy itself
868858
// before SBDebugger::Terminate() is called.

llvm/include/llvm/Support/Signals.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,6 @@ namespace sys {
8484
/// function. Note also that the handler may be executed on a different
8585
/// thread on some platforms.
8686
void SetInfoSignalFunction(void (*Handler)());
87-
88-
/// Registers a function to be called when a "pipe" signal is delivered to
89-
/// the process.
90-
///
91-
/// The "pipe" signal typically indicates a failed write to a pipe (SIGPIPE).
92-
/// The default installed handler calls `exit(EX_IOERR)`, causing the process
93-
/// to immediately exit with an IO error exit code.
94-
///
95-
/// This function is only applicable on POSIX systems.
96-
void SetPipeSignalFunction(void (*Handler)());
97-
9887
} // End sys namespace
9988
} // End llvm namespace
10089

llvm/lib/Support/Unix/Signals.inc

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,12 @@ using namespace llvm;
8282
static RETSIGTYPE SignalHandler(int Sig); // defined below.
8383
static RETSIGTYPE InfoSignalHandler(int Sig); // defined below.
8484

85-
static void DefaultPipeSignalFunction() {
86-
exit(EX_IOERR);
87-
}
88-
8985
using SignalHandlerFunctionType = void (*)();
9086
/// The function to call if ctrl-c is pressed.
9187
static std::atomic<SignalHandlerFunctionType> InterruptFunction =
9288
ATOMIC_VAR_INIT(nullptr);
9389
static std::atomic<SignalHandlerFunctionType> InfoSignalFunction =
9490
ATOMIC_VAR_INIT(nullptr);
95-
static std::atomic<SignalHandlerFunctionType> PipeSignalFunction =
96-
ATOMIC_VAR_INIT(DefaultPipeSignalFunction);
9791

9892
namespace {
9993
/// Signal-safe removal of files.
@@ -369,8 +363,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
369363

370364
// Send a special return code that drivers can check for, from sysexits.h.
371365
if (Sig == SIGPIPE)
372-
if (SignalHandlerFunctionType CurrentPipeFunction = PipeSignalFunction)
373-
CurrentPipeFunction();
366+
exit(EX_IOERR);
374367

375368
raise(Sig); // Execute the default handler.
376369
return;
@@ -410,11 +403,6 @@ void llvm::sys::SetInfoSignalFunction(void (*Handler)()) {
410403
RegisterHandlers();
411404
}
412405

413-
void llvm::sys::SetPipeSignalFunction(void (*Handler)()) {
414-
PipeSignalFunction.exchange(Handler);
415-
RegisterHandlers();
416-
}
417-
418406
// The public API
419407
bool llvm::sys::RemoveFileOnSignal(StringRef Filename,
420408
std::string* ErrMsg) {

llvm/lib/Support/Windows/Signals.inc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,9 +560,6 @@ void llvm::sys::SetInfoSignalFunction(void (*Handler)()) {
560560
// Unimplemented.
561561
}
562562

563-
void llvm::sys::SetPipeSignalFunction(void (*Handler)()) {
564-
// Unimplemented.
565-
}
566563

567564
/// Add a function to be called when a signal is delivered to the process. The
568565
/// handler can have a cookie passed to it to identify what instance of the

llvm/unittests/Support/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ add_llvm_unittest(SupportTests
5858
ReverseIterationTest.cpp
5959
ReplaceFileTest.cpp
6060
ScaledNumberTest.cpp
61-
SignalsTest.cpp
6261
SourceMgrTest.cpp
6362
SpecialCaseListTest.cpp
6463
StringPool.cpp

llvm/unittests/Support/SignalsTest.cpp

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)