]> sourceware.org Git - systemtap.git/commitdiff
Ignores signals when removing the temporary directory.
authorDavid Smith <dsmith@redhat.com>
Thu, 15 May 2008 20:52:12 +0000 (15:52 -0500)
committerDavid Smith <dsmith@redhat.com>
Thu, 15 May 2008 20:54:07 +0000 (15:54 -0500)
2008-05-15  David Smith  <dsmith@redhat.com>

* main.cxx (setup_signals): New function.
(main): Calls setup_signals() to setup signal handling.  When
removing the temporary directory, ignore signals.

ChangeLog
main.cxx

index 13f6254e8da0983ca39b30e464882038b94fb688..005af837d4d88db95304bddee6d7430deaa9a648 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-05-15  David Smith  <dsmith@redhat.com>
+
+       * main.cxx (setup_signals): New function.
+       (main): Calls setup_signals() to setup signal handling.  When
+       removing the temporary directory, ignore signals.
+
 2008-05-13  Ananth N Mavinakayanahalli <ananth@in.ibm.com>
        PR 5955.
        * parse.cxx (parser::parse_global): accept ";" terminated globals
index 2a1c0dfb8724fde2405745f4bbb3682d92d894bd..eadbd6948245614c657e21f95a4b4425f2405d04 100644 (file)
--- a/main.cxx
+++ b/main.cxx
@@ -261,6 +261,30 @@ void handle_interrupt (int /* sig */)
 }
 
 
+void
+setup_signals (sighandler_t handler)
+{
+  struct sigaction sa;
+
+  sa.sa_handler = handler;
+  sigemptyset (&sa.sa_mask);
+  if (handler != SIG_IGN)
+    {
+      sigaddset (&sa.sa_mask, SIGHUP);
+      sigaddset (&sa.sa_mask, SIGPIPE);
+      sigaddset (&sa.sa_mask, SIGINT);
+      sigaddset (&sa.sa_mask, SIGTERM);
+    }
+  sa.sa_flags = 0;
+  sa.sa_restorer = NULL;
+
+  sigaction (SIGHUP, &sa, NULL);
+  sigaction (SIGPIPE, &sa, NULL);
+  sigaction (SIGINT, &sa, NULL);
+  sigaction (SIGTERM, &sa, NULL);
+}
+
+
 int
 main (int argc, char * const argv [])
 {
@@ -698,10 +722,7 @@ main (int argc, char * const argv [])
 
   // Set up our handler to catch routine signals, to allow clean 
   // and reasonably timely exit.
-  signal (SIGHUP, handle_interrupt);
-  signal (SIGPIPE, handle_interrupt);
-  signal (SIGINT, handle_interrupt);
-  signal (SIGTERM, handle_interrupt);
+  setup_signals(&handle_interrupt);
 
   struct tms tms_before;
   times (& tms_before);
@@ -1022,6 +1043,10 @@ pass_5:
         clog << "Keeping temporary directory \"" << s.tmpdir << "\"" << endl;
       else
         {
+         // Ignore signals while we're deleting the temporary directory.
+         setup_signals (SIG_IGN);
+
+         // Remove the temporary directory.
           string cleanupcmd = "rm -rf ";
           cleanupcmd += s.tmpdir;
           if (s.verbose>1) clog << "Running " << cleanupcmd << endl;
This page took 0.041598 seconds and 5 git commands to generate.