catch signals to clean up pxshm files
authorGengbin Zheng <gzheng@illinois.edu>
Tue, 31 Jan 2012 21:21:37 +0000 (15:21 -0600)
committerGengbin Zheng <gzheng@illinois.edu>
Tue, 31 Jan 2012 21:21:37 +0000 (15:21 -0600)
src/arch/util/machine-pxshm.c

index 2e192cd4a65d9f61d4747caefc7ba25930fdfb85..841684e54c8df30cf82b7ca3ecb9d31b3072788a 100644 (file)
@@ -34,6 +34,7 @@ There are three options here for synchronization:
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
+#include <signal.h>
 
 
 /************** 
@@ -191,6 +192,13 @@ void calculateNodeSizeAndRank(char **);
 void setupSharedBuffers();
 void initAllSendQs();
 
+void CmiExitPxshm();
+
+static void cleanupOnAllSigs(int signo)
+{
+    CmiExitPxshm();
+}
+
 /******************
  *     Initialization routine
  *     currently just testing start up
@@ -240,6 +248,14 @@ void CmiInitPxshm(char **argv){
        pxshmContext->lockRecvCount = 0;
 #endif
 
+        signal(SIGSEGV, cleanupOnAllSigs);
+        signal(SIGFPE, cleanupOnAllSigs);
+        signal(SIGILL, cleanupOnAllSigs);
+        signal(SIGTERM, cleanupOnAllSigs);
+        signal(SIGABRT, cleanupOnAllSigs);
+        signal(SIGQUIT, cleanupOnAllSigs);
+        signal(SIGBUS, cleanupOnAllSigs);
+
 #if 0
         char name[64];
         gethostname(name,64);