Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Kill the MCed process if/when the MCer dies
[simgrid.git] / src / mc / simgrid_mc.cpp
index 409acb5..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:
@@ -77,23 +82,7 @@ static int do_parent(int socket, pid_t child)
     mc_server = new s_mc_server(child, socket);
     mc_server->start();
     MC_init_pid(child, socket);
-
-    if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
-      mc_server->loop();
-    }
-
-    else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0') {
-      if (mc_reduce_kind == e_mc_reduce_unset)
-        mc_reduce_kind = e_mc_reduce_dpor;
-      XBT_INFO("Check a safety property");
-      MC_wait_for_requests();
-      MC_modelcheck_safety();
-    }
-
-    else {
-      mc_server->loop();
-    }
-
+    MC_do_the_modelcheck_for_real();
     mc_server->shutdown();
     mc_server->exit();
   }