about summary refs log tree commit diff
diff options
context:
space:
mode:
-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 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");