about summary refs log tree commit diff
path: root/src/libmain
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-11-04T15·34+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-11-04T15·34+0000
commit9311ab76a523de516b6bc98afda9e4b790225514 (patch)
tree1ff31ad158d89a179d1f3b9062b842e12ce029f6 /src/libmain
parent5bf939885a8bfca9b66a2440bf52330c5fde6477 (diff)
* Install signal handlers for SIGTERM and SIGHUP. This ensures that
  Nix is properly shut down when it receives those signals.  In
  particular this ensures that killing the garbage collector doesn't
  cause a subsequent database recovery.

Diffstat (limited to 'src/libmain')
-rw-r--r--src/libmain/shared.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index bc7b2dd51fef..709b6116a67e 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -120,6 +120,10 @@ static void initAndRun(int argc, char * * argv)
     act.sa_flags = 0;
     if (sigaction(SIGINT, &act, &oact))
         throw SysError("installing handler for SIGINT");
+    if (sigaction(SIGTERM, &act, &oact))
+        throw SysError("installing handler for SIGTERM");
+    if (sigaction(SIGHUP, &act, &oact))
+        throw SysError("installing handler for SIGHUP");
 
     /* Ignore SIGPIPE. */
     act.sa_handler = SIG_IGN;