forked from lix-project/lix
libutil: remove the interrupt-blocking code
The interrupt-blocking code was originally introduced 20 years ago so that trying to log an error message does not result in an interrupt exception being thrown and then going unhandled (c8d3882cdc
). However, the logging code does not check for interrupts any more (054be50257
), so this reasoning is no longer applicable. Delete this code so that later interrupts are unblocked again, for example in the next line entered into the repl. Closes: lix-project/lix#296 Change-Id:I48253f5f4272e75001148c13046e709ef5427fbd
This commit is contained in:
parent
f6dc40cd1c
commit
914b0febf7
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 builds in the REPL works more than once
|
||||
cls: 1097
|
||||
---
|
||||
|
||||
Builds in the REPL can be interrupted by pressing Ctrl+C.
|
||||
Previously, this only worked once per REPL session; further attempts would be ignored.
|
||||
This issue is now fixed, so that builds can be canceled consistently.
|
|
@ -320,16 +320,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) {
|
||||
|
|
|
@ -9,21 +9,14 @@ namespace nix {
|
|||
|
||||
std::atomic<bool> _isInterrupted = false;
|
||||
|
||||
static thread_local bool interruptThrown = false;
|
||||
thread_local std::function<bool()> interruptCheck;
|
||||
|
||||
void setInterruptThrown()
|
||||
{
|
||||
interruptThrown = true;
|
||||
}
|
||||
|
||||
void _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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,6 @@ extern std::atomic<bool> _isInterrupted;
|
|||
|
||||
extern thread_local std::function<bool()> interruptCheck;
|
||||
|
||||
void setInterruptThrown();
|
||||
|
||||
void _interrupted();
|
||||
|
||||
void inline checkInterrupt()
|
||||
|
|
Loading…
Reference in a new issue