Przeglądaj źródła

* Call fatal() on SIGINT to cleanup

Bryan Drewery 15 lat temu
rodzic
commit
bfe4b4f556
3 zmienionych plików z 17 dodań i 1 usunięć
  1. 15 0
      src/debug.c
  2. 1 0
      src/debug.h
  3. 1 1
      src/shell.c

+ 15 - 0
src/debug.c

@@ -274,6 +274,20 @@ got_usr1(int z)
 //  reload_bin_data();
 }
 
+void got_int(int z)
+{
+  signal(SIGINT, SIG_DFL);
+  putlog(LOG_DEBUG, "*", "GOT SIGINT -- QUITTING");
+  fatal("Received SIGINT", 0);
+  sdprintf("HERE");
+  exit(1);
+#ifdef DEBUG
+  raise(SIGINT);
+#else
+  exit(1);
+#endif /* DEBUG */
+}
+
 void init_signals() 
 {
   signal(SIGBUS, got_bus);
@@ -287,4 +301,5 @@ void init_signals()
   signal(SIGALRM, got_alarm);
   signal(SIGHUP, got_hup);
   signal(SIGUSR1, got_usr1);
+  signal(SIGINT, got_int);
 }

+ 1 - 0
src/debug.h

@@ -37,4 +37,5 @@ void setlimits();
 void sdprintf (const char *, ...) __attribute__((format(printf, 1, 2)));
 void init_signals();
 void init_debug();
+void got_int(int z);
 #endif /* !_DEBUG_H */

+ 1 - 1
src/shell.c

@@ -292,7 +292,7 @@ void check_trace(int start)
     signal(SIGINT, got_sigtrap);
     traced = 1;
     raise(SIGINT);
-    signal(SIGINT, SIG_DFL);
+    signal(SIGINT, got_int);
   }
 
   if (traced) {