aboutsummaryrefslogtreecommitdiff
path: root/src/nix/repl.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-04-25 19:19:15 +0200
committerEelco Dolstra <edolstra@gmail.com>2017-04-25 19:19:48 +0200
commit6734c18c99f8fa33a50a3045a8dd915bbf084255 (patch)
treed84b193f624b83bb0ee17ef598e590b5f980263f /src/nix/repl.cc
parent23aa1619daace5db30233a53183911adb42322d9 (diff)
nix repl: Fix Ctrl-C
Diffstat (limited to 'src/nix/repl.cc')
-rw-r--r--src/nix/repl.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nix/repl.cc b/src/nix/repl.cc
index ae3050264..17203d3c2 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");