mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
nix repl: Fix Ctrl-C
This commit is contained in:
parent
23aa1619da
commit
6734c18c99
1 changed files with 10 additions and 0 deletions
|
@ -217,6 +217,13 @@ bool NixRepl::getLine(string & input, const char * prompt)
|
|||
if (sigaction(SIGINT, &act, &old))
|
||||
throw SysError("installing handler for SIGINT");
|
||||
|
||||
static sigset_t savedSignalMask, set;
|
||||
sigemptyset(&set);
|
||||
sigaddset(&set, SIGINT);
|
||||
|
||||
if (sigprocmask(SIG_UNBLOCK, &set, &savedSignalMask))
|
||||
throw SysError("unblocking SIGINT");
|
||||
|
||||
if (sigsetjmp(sigintJmpBuf, 1)) {
|
||||
input.clear();
|
||||
} else {
|
||||
|
@ -236,6 +243,9 @@ bool NixRepl::getLine(string & input, const char * prompt)
|
|||
|
||||
_isInterrupted = 0;
|
||||
|
||||
if (sigprocmask(SIG_SETMASK, &savedSignalMask, nullptr))
|
||||
throw SysError("restoring signals");
|
||||
|
||||
if (sigaction(SIGINT, &old, 0))
|
||||
throw SysError("restoring handler for SIGINT");
|
||||
|
||||
|
|
Loading…
Reference in a new issue