about summary refs log tree commit diff
path: root/src/libexpr/nixexpr.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-01-15T20·23+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-01-15T20·23+0000
commit447089a5f699f085661287dec4b3d88219f67068 (patch)
treee460c615181db3e6b6f8b48e4e934b372ecac043 /src/libexpr/nixexpr.cc
parent08719c6c97e25fb362eeb7463d8b764ecefc53cb (diff)
* Catch SIGINT to terminate cleanly when the user tries to interrupt
  Nix.  This is to prevent Berkeley DB from becoming wedged.

  Unfortunately it is not possible to throw C++ exceptions from a
  signal handler.  In fact, you can't do much of anything except
  change variables of type `volatile sig_atomic_t'.  So we set an
  interrupt flag in the signal handler and check it at various
  strategic locations in the code (by calling checkInterrupt()).
  Since this is unlikely to cover all cases (e.g., (semi-)infinite
  loops), sometimes SIGTERM may now be required to kill Nix.

Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r--src/libexpr/nixexpr.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index 816b39dc1ae3..dd0f5d58af27 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -87,6 +87,8 @@ string aterm2String(ATerm t)
 
 ATerm bottomupRewrite(TermFun & f, ATerm e)
 {
+    checkInterrupt();
+
     if (ATgetType(e) == AT_APPL) {
         AFun fun = ATgetAFun(e);
         int arity = ATgetArity(fun);
@@ -149,6 +151,8 @@ Expr makeAttrs(const ATermMap & attrs)
 
 Expr substitute(const ATermMap & subs, Expr e)
 {
+    checkInterrupt();
+
     ATMatcher m;
     string s;