diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/thread-pool.cc | 7 | ||||
-rw-r--r-- | src/libutil/util.cc | 6 | ||||
-rw-r--r-- | src/libutil/util.hh | 2 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/libutil/thread-pool.cc b/src/libutil/thread-pool.cc index 819aed748..743038b58 100644 --- a/src/libutil/thread-pool.cc +++ b/src/libutil/thread-pool.cc @@ -55,9 +55,10 @@ void ThreadPool::process() work(); } catch (std::exception & e) { auto state_(state.lock()); - if (state_->exception) - printMsg(lvlError, format("error: %s") % e.what()); - else { + if (state_->exception) { + if (!dynamic_cast<Interrupted*>(&e)) + printMsg(lvlError, format("error: %s") % e.what()); + } else { state_->exception = std::current_exception(); wakeup.notify_all(); } diff --git a/src/libutil/util.cc b/src/libutil/util.cc index d4ac3fb60..55d490992 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -1062,13 +1062,15 @@ void restoreSIGPIPE() volatile sig_atomic_t _isInterrupted = 0; +thread_local bool interruptThrown = false; + void _interrupted() { /* Block user interrupts while an exception is being handled. Throwing an exception while another exception is being handled kills the program! */ - if (!std::uncaught_exception()) { - _isInterrupted = 0; + if (!interruptThrown && !std::uncaught_exception()) { + interruptThrown = true; throw Interrupted("interrupted by the user"); } } diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 0a72cc592..20bd62a0e 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -316,6 +316,8 @@ void restoreSIGPIPE(); extern volatile sig_atomic_t _isInterrupted; +extern thread_local bool interruptThrown; + void _interrupted(); void inline checkInterrupt() |