aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralois31 <alois1@gmx-topmail.de>2024-05-15 15:46:11 +0000
committerGerrit Code Review <gerrit@lix-systems>2024-05-15 15:46:11 +0000
commit0903a99bade6891dd3deba48982d87b7dc29be18 (patch)
treeb027f5c1cbf384932c87b2ec163fe448bee8f26d /src
parent312f66b307bc1f857bf8a6927375b0aa365e2f23 (diff)
parenteeb7e718101fbc5c53d3e070d8987e468047d804 (diff)
Merge changes I8456c47b,I48253f5f into main
* changes: repl: clear the interrupt before reading the next line libutil: remove the interrupt-blocking code
Diffstat (limited to 'src')
-rw-r--r--src/libcmd/repl.cc4
-rw-r--r--src/libmain/shared.cc11
-rw-r--r--src/libutil/signals.cc9
-rw-r--r--src/libutil/signals.hh2
4 files changed, 4 insertions, 22 deletions
diff --git a/src/libcmd/repl.cc b/src/libcmd/repl.cc
index 696bb3c12..34de2160a 100644
--- a/src/libcmd/repl.cc
+++ b/src/libcmd/repl.cc
@@ -262,6 +262,8 @@ ReplExitStatus NixRepl::mainLoop()
std::string input;
while (true) {
+ _isInterrupted = false;
+
// When continuing input from previous lines, don't print a prompt, just align to the same
// number of chars as the prompt.
if (!interacter->getLine(input, input.empty() ? ReplPromptType::ReplPrompt : ReplPromptType::ContinuationPrompt)) {
@@ -424,8 +426,6 @@ ProcessLineResult NixRepl::processLine(std::string line)
if (line.empty())
return ProcessLineResult::PromptAgain;
- _isInterrupted = false;
-
std::string command, arg;
if (line[0] == ':') {
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 9d4dd41ed..96ecbac8f 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -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) {
diff --git a/src/libutil/signals.cc b/src/libutil/signals.cc
index f5c79b325..41fdc9dc8 100644
--- a/src/libutil/signals.cc
+++ b/src/libutil/signals.cc
@@ -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");
}
}
diff --git a/src/libutil/signals.hh b/src/libutil/signals.hh
index c58dc37cf..71593df95 100644
--- a/src/libutil/signals.hh
+++ b/src/libutil/signals.hh
@@ -22,8 +22,6 @@ extern std::atomic<bool> _isInterrupted;
extern thread_local std::function<bool()> interruptCheck;
-void setInterruptThrown();
-
void _interrupted();
void inline checkInterrupt()