diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-04-25T17·19+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-04-25T17·19+0200 |
commit | 6734c18c99f8fa33a50a3045a8dd915bbf084255 (patch) | |
tree | d84b193f624b83bb0ee17ef598e590b5f980263f /src/nix | |
parent | 23aa1619daace5db30233a53183911adb42322d9 (diff) |
nix repl: Fix Ctrl-C
Diffstat (limited to 'src/nix')
-rw-r--r-- | src/nix/repl.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc index ae30502641a4..17203d3c299f 100644 --- a/src/nix/repl.cc +++ b/src/nix/repl.cc @@ -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"); |