mirror of
https://github.com/NixOS/nix.git
synced 2025-12-05 00:21:01 +01:00
libutil/signals: Get rid of setInterruptThrown
The interrupting code is no longer relevant. Since
054be50257 logging no longer checks for interrupts
and in general logging should be noexcept.
Co-authored-by: Alois Wohlschlager <alois1@gmx-topmail.de>
Cherry-picked-from: https://gerrit.lix.systems/c/lix/+/1097
This commit is contained in:
parent
048a58d331
commit
c0c1bde506
5 changed files with 10 additions and 31 deletions
8
doc/manual/rl-next/repl-interrupt.md
Normal file
8
doc/manual/rl-next/repl-interrupt.md
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
synopsis: Interrupting REPL commands works more than once
|
||||
issues: [13481]
|
||||
---
|
||||
|
||||
Previously, this only worked once per REPL session; further attempts would be ignored.
|
||||
This issue is now fixed, so REPL commands such as `:b` or `:p` can be canceled consistently.
|
||||
This is a cherry-pick of the change from the [Lix project](https://gerrit.lix.systems/c/lix/+/1097).
|
||||
|
|
@ -321,16 +321,7 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
|
|||
|
||||
std::string error = ANSI_RED "error:" ANSI_NORMAL " ";
|
||||
try {
|
||||
try {
|
||||
fun();
|
||||
} catch (...) {
|
||||
/* Subtle: we have to make sure that any `interrupted'
|
||||
condition is discharged before we reach printMsg()
|
||||
below, since otherwise it will throw an (uncaught)
|
||||
exception. */
|
||||
setInterruptThrown();
|
||||
throw;
|
||||
}
|
||||
fun();
|
||||
} catch (Exit & e) {
|
||||
return e.status;
|
||||
} catch (UsageError & e) {
|
||||
|
|
|
|||
|
|
@ -21,11 +21,6 @@ static inline void setInterrupted(bool isInterrupted);
|
|||
*/
|
||||
static inline bool getInterrupted();
|
||||
|
||||
/**
|
||||
* @note Does nothing on Windows
|
||||
*/
|
||||
void setInterruptThrown();
|
||||
|
||||
/**
|
||||
* @note Does nothing on Windows
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -12,24 +12,14 @@ using namespace unix;
|
|||
|
||||
std::atomic<bool> unix::_isInterrupted = false;
|
||||
|
||||
namespace unix {
|
||||
static thread_local bool interruptThrown = false;
|
||||
}
|
||||
|
||||
thread_local std::function<bool()> unix::interruptCheck;
|
||||
|
||||
void setInterruptThrown()
|
||||
{
|
||||
unix::interruptThrown = true;
|
||||
}
|
||||
|
||||
void unix::_interrupted()
|
||||
{
|
||||
/* Block user interrupts while an exception is being handled.
|
||||
Throwing an exception while another exception is being handled
|
||||
kills the program! */
|
||||
if (!interruptThrown && !std::uncaught_exceptions()) {
|
||||
interruptThrown = true;
|
||||
if (!std::uncaught_exceptions()) {
|
||||
throw Interrupted("interrupted by the user");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,6 @@ static inline bool getInterrupted()
|
|||
return false;
|
||||
}
|
||||
|
||||
inline void setInterruptThrown()
|
||||
{
|
||||
/* Do nothing for now */
|
||||
}
|
||||
|
||||
static inline bool isInterrupted()
|
||||
{
|
||||
/* Do nothing for now */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue