* 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.
This commit is contained in:
Eelco Dolstra 2004-01-15 20:23:55 +00:00
parent 08719c6c97
commit 447089a5f6
13 changed files with 86 additions and 4 deletions

View file

@ -227,6 +227,8 @@ Expr evalExpr2(EvalState & state, Expr e)
Expr evalExpr(EvalState & state, Expr e)
{
checkInterrupt();
startNest(nest, lvlVomit,
format("evaluating expression: %1%") % e);

View file

@ -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;

View file

@ -26,6 +26,8 @@ struct Cleanup : TermFun
virtual ATerm operator () (ATerm e)
{
checkInterrupt();
ATMatcher m;
string s;