mirror of
https://github.com/NixOS/nix.git
synced 2025-12-05 08:31:00 +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).
|
||||||
|
|
@ -320,17 +320,8 @@ int handleExceptions(const std::string & programName, std::function<void()> fun)
|
||||||
ErrorInfo::programName = baseNameOf(programName);
|
ErrorInfo::programName = baseNameOf(programName);
|
||||||
|
|
||||||
std::string error = ANSI_RED "error:" ANSI_NORMAL " ";
|
std::string error = ANSI_RED "error:" ANSI_NORMAL " ";
|
||||||
try {
|
|
||||||
try {
|
try {
|
||||||
fun();
|
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;
|
|
||||||
}
|
|
||||||
} catch (Exit & e) {
|
} catch (Exit & e) {
|
||||||
return e.status;
|
return e.status;
|
||||||
} catch (UsageError & e) {
|
} catch (UsageError & e) {
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,6 @@ static inline void setInterrupted(bool isInterrupted);
|
||||||
*/
|
*/
|
||||||
static inline bool getInterrupted();
|
static inline bool getInterrupted();
|
||||||
|
|
||||||
/**
|
|
||||||
* @note Does nothing on Windows
|
|
||||||
*/
|
|
||||||
void setInterruptThrown();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @note Does nothing on Windows
|
* @note Does nothing on Windows
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,14 @@ using namespace unix;
|
||||||
|
|
||||||
std::atomic<bool> unix::_isInterrupted = false;
|
std::atomic<bool> unix::_isInterrupted = false;
|
||||||
|
|
||||||
namespace unix {
|
|
||||||
static thread_local bool interruptThrown = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
thread_local std::function<bool()> unix::interruptCheck;
|
thread_local std::function<bool()> unix::interruptCheck;
|
||||||
|
|
||||||
void setInterruptThrown()
|
|
||||||
{
|
|
||||||
unix::interruptThrown = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void unix::_interrupted()
|
void unix::_interrupted()
|
||||||
{
|
{
|
||||||
/* Block user interrupts while an exception is being handled.
|
/* Block user interrupts while an exception is being handled.
|
||||||
Throwing an exception while another exception is being handled
|
Throwing an exception while another exception is being handled
|
||||||
kills the program! */
|
kills the program! */
|
||||||
if (!interruptThrown && !std::uncaught_exceptions()) {
|
if (!std::uncaught_exceptions()) {
|
||||||
interruptThrown = true;
|
|
||||||
throw Interrupted("interrupted by the user");
|
throw Interrupted("interrupted by the user");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,6 @@ static inline bool getInterrupted()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setInterruptThrown()
|
|
||||||
{
|
|
||||||
/* Do nothing for now */
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool isInterrupted()
|
static inline bool isInterrupted()
|
||||||
{
|
{
|
||||||
/* Do nothing for now */
|
/* Do nothing for now */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue