-static int do_child(int socket, char** argv)
-{
- XBT_DEBUG("Inside the child process PID=%i", (int) getpid());
-
-#ifdef __linux__
- // Make sure we do not outlive our parent:
- sigset_t mask;
- sigemptyset (&mask);
- if (sigprocmask(SIG_SETMASK, &mask, nullptr) < 0) {
- std::perror ("sigprocmask");
- return SIMGRID_MC_EXIT_ERROR;
- }
-
- if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0) {
- std::perror("simgrid-mc");
- return SIMGRID_MC_EXIT_ERROR;
- }
-#endif
-
- int res;
-
- // Remove CLOEXEC in order to pass the socket to the exec-ed program:
- int fdflags = fcntl(socket, F_GETFD, 0);
- if (fdflags == -1) {
- std::perror("simgrid-mc");
- return SIMGRID_MC_EXIT_ERROR;
- }
- if (fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) == -1) {
- std::perror("simgrid-mc");
- return SIMGRID_MC_EXIT_ERROR;
- }
-
- XBT_DEBUG("CLOEXEC removed on socket %i", socket);
-
- // Set environment:
- setenv(MC_ENV_VARIABLE, "1", 1);
-
- // Disable lazy relocation in the model-ched process.
- // We don't want the model-checked process to modify its .got.plt during
- // snapshot.
- setenv("LC_BIND_NOW", "1", 1);
-
- char buffer[64];
- res = std::snprintf(buffer, sizeof(buffer), "%i", socket);
- if ((size_t) res >= sizeof(buffer) || res == -1)
- return SIMGRID_MC_EXIT_ERROR;
- setenv(MC_ENV_SOCKET_FD, buffer, 1);
-
- execvp(argv[1], argv+1);
- XBT_ERROR("Could not execute the child process");
- return SIMGRID_MC_EXIT_ERROR;
-}
-
-static int do_parent(int socket, pid_t child)
-{
- XBT_DEBUG("Inside the parent process");
- if (mc_model_checker)
- xbt_die("MC server already present");
- try {
- mc_mode = MC_MODE_SERVER;
- std::unique_ptr<simgrid::mc::Process> process(new simgrid::mc::Process(child, socket));
- process->privatized(sg_cfg_get_boolean("smpi/privatize_global_variables"));
- mc_model_checker = new simgrid::mc::ModelChecker(std::move(process));
- mc_model_checker->start();
- int res = 0;
- if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
- res = MC_modelcheck_comm_determinism();
- else if (!_sg_mc_property_file || _sg_mc_property_file[0] == '\0')
- res = MC_modelcheck_safety();
- else
- res = MC_modelcheck_liveness();
- mc_model_checker->shutdown();
- return res;
- }
- catch(std::exception& e) {
- XBT_ERROR("Exception: %s", e.what());
- return SIMGRID_MC_EXIT_ERROR;
- }
-}
-
-static char** argvdup(int argc, char** argv)