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))
|
if (sigaction(SIGINT, &act, &old))
|
||||||
throw SysError("installing handler for SIGINT");
|
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)) {
|
if (sigsetjmp(sigintJmpBuf, 1)) {
|
||||||
input.clear();
|
input.clear();
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,6 +243,9 @@ bool NixRepl::getLine(string & input, const char * prompt)
|
||||||
|
|
||||||
_isInterrupted = 0;
|
_isInterrupted = 0;
|
||||||
|
|
||||||
|
if (sigprocmask(SIG_SETMASK, &savedSignalMask, nullptr))
|
||||||
|
throw SysError("restoring signals");
|
||||||
|
|
||||||
if (sigaction(SIGINT, &old, 0))
|
if (sigaction(SIGINT, &old, 0))
|
||||||
throw SysError("restoring handler for SIGINT");
|
throw SysError("restoring handler for SIGINT");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue