about summary refs log tree commit diff
path: root/src/libmain/shared.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-02-03T21·22+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-02-03T21·22+0000
commitf859a8d3c33cc275f41d983bfeff2a21a9f88f1b (patch)
tree8f242f4fc9d094a93b416f03b829d0f58af37bf0 /src/libmain/shared.cc
parentc45de33c67a7273fc87a654696d15010df0f5c6d (diff)
* While waiting for a lock, print a sign of life every 5 minutes.
  This prevents remote builders from being killed by the
  `max-silent-time' inactivity monitor while they are waiting for a
  long garbage collection to finish.  This happens fairly often in the
  Hydra build farm.

Diffstat (limited to 'src/libmain/shared.cc')
-rw-r--r--src/libmain/shared.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index d9cf9a86262a..d48e2ad69655 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -31,6 +31,11 @@ static void sigintHandler(int signo)
 }
 
 
+static void sigalrmHandler(int signo)
+{
+}
+
+
 Path makeRootName(const Path & gcRoot, int & counter)
 {
     counter++;
@@ -160,6 +165,14 @@ static void initAndRun(int argc, char * * argv)
     if (sigaction(SIGPIPE, &act, 0))
         throw SysError("ignoring SIGPIPE");
 
+    /* Catch SIGALRM with an empty handler (we just need it to get an
+       EINTR from blocking system calls). */
+    act.sa_handler = sigalrmHandler;
+    sigfillset(&act.sa_mask);
+    act.sa_flags = 0;
+    if (sigaction(SIGALRM, &act, 0))
+        throw SysError("installing handler for SIGALRM");
+
     /* Reset SIGCHLD to its default. */
     act.sa_handler = SIG_DFL;
     act.sa_flags = 0;