From 6734c18c99f8fa33a50a3045a8dd915bbf084255 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 25 Apr 2017 19:19:15 +0200 Subject: [PATCH] nix repl: Fix Ctrl-C --- src/nix/repl.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) 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");