Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Kill the MCed process if/when the MCer dies
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 10 Apr 2015 10:15:27 +0000 (12:15 +0200)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 10 Apr 2015 10:44:45 +0000 (12:44 +0200)
src/mc/simgrid_mc.cpp

index 0c8899b..71d0388 100644 (file)
@@ -18,6 +18,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
+#include <sys/prctl.h>
 
 #include <xbt/log.h>
 
@@ -38,6 +39,10 @@ static const bool trace = true;
 static int do_child(int socket, char** argv)
 {
   XBT_DEBUG("Inside the child process PID=%i", (int) getpid());
+  if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0) {
+    std::perror("simgrid-mc");
+    return MC_SERVER_ERROR;
+  }
   int res;
 
   // Remove CLOEXEC in order to pass the socket to the exec-ed program: