================
@@ -781,15 +784,61 @@ int main(int argc, char const *argv[]) {
// Setup LLDB signal handlers once the debugger has been initialized.
SBDebugger::PrintDiagnosticsOnError();
- // FIXME: Migrate the SIGINT handler to be handled by the signal loop below.
+#ifdef _WIN32
signal(SIGINT, sigint_handler);
-#if !defined(_WIN32)
+#else
signal(SIGPIPE, SIG_IGN);
+ // Capture the main thread's id so the signal thread can target it.
+ pthread_t main_thread = pthread_self();
+
+ // Set when the signal thread sends itself a SIGINT to wake the main thread.
+ // The next SIGINT callback invocation observes this flag and skips the work.
+ std::atomic<bool> skip_next_sigint{false};
+
// Handle signals in a MainLoop running on a separate thread.
MainLoop signal_loop;
Status signal_status;
+ auto sigint_handler = signal_loop.RegisterSignal(
+ SIGINT,
+ [&, main_thread](MainLoopBase &) {
----------------
labath wrote:
I think this is the right incantation.
```suggestion
[&, main_thread = pthread_self(), skip_next_sigint = false](MainLoopBase
&) mutable {
```
https://github.com/llvm/llvm-project/pull/195959
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits