- // We need to keep the original parameters in order to pass them to the
- // model-checked process:
- int argc_copy = argc;
- char** argv_copy = argvdup(argc, argv);
- xbt_log_init(&argc_copy, argv_copy);
- sg_config_init(&argc_copy, argv_copy);
-
- if (argc < 2)
- xbt_die("Missing arguments.\n");
-
- bool server_mode = true;
- char* env = std::getenv("SIMGRID_MC_MODE");
- if (env) {
- if (std::strcmp(env, "server") == 0)
- server_mode = true;
- else if (std::strcmp(env, "standalone") == 0)
- server_mode = false;
- else
- xbt_die("Unrecognised value for SIMGRID_MC_MODE (server/standalone)");
- }
-
- if (!server_mode) {
- setenv(MC_ENV_VARIABLE, "1", 1);
- execvp(argv[1], argv+1);
+ try {
+ if (argc < 2)
+ xbt_die("Missing arguments.\n");
+
+ _sg_do_model_check = 1;
+
+ // The initialisation function can touch argv.
+ // We need to keep the original parameters in order to pass them to the
+ // model-checked process so we make a copy of them:
+ int argc_copy = argc;
+ char** argv_copy = argvdup(argc, argv);
+ xbt_log_init(&argc_copy, argv_copy);
+ sg_config_init(&argc_copy, argv_copy);
+
+ int sock;
+ pid_t model_checked_pid;
+ std::tie(model_checked_pid, sock) = create_model_checked(argv);
+ XBT_DEBUG("Inside the parent process");
+ if (mc_model_checker)
+ xbt_die("MC server already present");