Skip to content

Commit 7f3ad17

Browse files
authored
Merge pull request #14687 from NixOS/repl-print-interrupt
libutil/signals: Get rid of setInterruptThrown
2 parents d261557 + c0c1bde commit 7f3ad17

File tree

5 files changed

+10
-31
lines changed

5 files changed

+10
-31
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
synopsis: Interrupting REPL commands works more than once
3+
issues: [13481]
4+
---
5+
6+
Previously, this only worked once per REPL session; further attempts would be ignored.
7+
This issue is now fixed, so REPL commands such as `:b` or `:p` can be canceled consistently.
8+
This is a cherry-pick of the change from the [Lix project](https://gerrit.lix.systems/c/lix/+/1097).

src/libmain/shared.cc

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,16 +321,7 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
321321

322322
std::string error = ANSI_RED "error:" ANSI_NORMAL " ";
323323
try {
324-
try {
325-
fun();
326-
} catch (...) {
327-
/* Subtle: we have to make sure that any `interrupted'
328-
condition is discharged before we reach printMsg()
329-
below, since otherwise it will throw an (uncaught)
330-
exception. */
331-
setInterruptThrown();
332-
throw;
333-
}
324+
fun();
334325
} catch (Exit & e) {
335326
return e.status;
336327
} catch (UsageError & e) {

src/libutil/include/nix/util/signals.hh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ static inline void setInterrupted(bool isInterrupted);
2121
*/
2222
static inline bool getInterrupted();
2323

24-
/**
25-
* @note Does nothing on Windows
26-
*/
27-
void setInterruptThrown();
28-
2924
/**
3025
* @note Does nothing on Windows
3126
*/

src/libutil/unix/signals.cc

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,14 @@ using namespace unix;
1212

1313
std::atomic<bool> unix::_isInterrupted = false;
1414

15-
namespace unix {
16-
static thread_local bool interruptThrown = false;
17-
}
18-
1915
thread_local std::function<bool()> unix::interruptCheck;
2016

21-
void setInterruptThrown()
22-
{
23-
unix::interruptThrown = true;
24-
}
25-
2617
void unix::_interrupted()
2718
{
2819
/* Block user interrupts while an exception is being handled.
2920
Throwing an exception while another exception is being handled
3021
kills the program! */
31-
if (!interruptThrown && !std::uncaught_exceptions()) {
32-
interruptThrown = true;
22+
if (!std::uncaught_exceptions()) {
3323
throw Interrupted("interrupted by the user");
3424
}
3525
}

src/libutil/windows/include/nix/util/signals-impl.hh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ static inline bool getInterrupted()
1717
return false;
1818
}
1919

20-
inline void setInterruptThrown()
21-
{
22-
/* Do nothing for now */
23-
}
24-
2520
static inline bool isInterrupted()
2621
{
2722
/* Do nothing for now */

0 commit comments

Comments
 (0)