Skip to content

Commit 3910c87

Browse files
committed
[Frontend] Respect SIGINT
Make sure we set the default handler for `SIGINT` before LLVM sets its own handler for it. This ensures we terminate on receiving SIGINT.
1 parent 1c1b6f7 commit 3910c87

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/DriverTool/driver.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "llvm/TargetParser/Host.h"
5151
#include "llvm/TargetParser/Triple.h"
5252

53+
#include <csignal>
5354
#include <memory>
5455
#include <stdlib.h>
5556

@@ -468,6 +469,11 @@ int swift::mainEntry(int argc_, const char **argv_) {
468469
llvm::transform(utf8Args, std::back_inserter(utf8CStrs),
469470
std::mem_fn(&std::string::c_str));
470471
argv_ = utf8CStrs.data();
472+
#else
473+
// Set SIGINT to the default handler, ensuring we exit. This needs to be set
474+
// before PROGRAM_START/INITIALIZE_LLVM since LLVM will set its own signal
475+
// handler that does some cleanup before delegating to the original handler.
476+
std::signal(SIGINT, SIG_DFL);
471477
#endif
472478
// Expand any response files in the command line argument vector - arguments
473479
// may be passed through response files in the event of command line length

0 commit comments

Comments
 (0)