From 5a4df9dd3a71dfd841506bf9953a32cc7a047421 Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sat, 25 May 2019 19:19:03 -0700 Subject: [PATCH] Use sigint_checker_t in debug_thread_error --- src/common.cpp | 6 +++--- src/signal.cpp | 7 +++++++ src/signal.h | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/common.cpp b/src/common.cpp index 5f59edee3..efd2c19d0 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -55,6 +55,7 @@ #include "future_feature_flags.h" #include "global_safety.h" #include "proc.h" +#include "signal.h" #include "wildcard.h" #include "wutil.h" // IWYU pragma: keep @@ -2271,9 +2272,8 @@ extern "C" { [[gnu::noinline]] void debug_thread_error(void) { // Wait for a SIGINT. We can't use sigsuspend() because the signal may be delivered on another // thread. - auto &tm = topic_monitor_t::principal(); - auto gens = tm.current_generations(); - tm.check(&gens, {topic_t::sighupint}, true /* wait */); + sigint_checker_t sigint; + sigint.wait(); } } diff --git a/src/signal.cpp b/src/signal.cpp index 52c643473..8e2be099f 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -431,3 +431,10 @@ bool sigint_checker_t::check() { this->gen_ = gen; return changed; } + +void sigint_checker_t::wait() { + auto &tm = topic_monitor_t::principal(); + generation_list_t gens{}; + gens[topic_t::sighupint] = this->gen_; + tm.check(&gens, {topic_t::sighupint}, true /* wait */); +} diff --git a/src/signal.h b/src/signal.h index 44aaa4e85..be0011203 100644 --- a/src/signal.h +++ b/src/signal.h @@ -42,6 +42,9 @@ class sigint_checker_t { /// Check if a sigint has been delivered since the last call to check(), or since the detector /// was created. bool check(); + + /// Wait until a sigint is delivered. + void wait(); }; #endif