- XBT_DEBUG("Inside the child process PID=%i", (int) getpid());
-
-#ifdef __linux__
- // Make sure we do not outlive our parent:
- if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0) {
- std::perror("simgrid-mc");
- return MC_SERVER_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 MC_SERVER_ERROR;
- }
- if (fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) == -1) {
- std::perror("simgrid-mc");
- return MC_SERVER_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 MC_SERVER_ERROR;
- setenv(MC_ENV_SOCKET_FD, buffer, 1);
+ char** argv_copy = xbt_new(char*, argc+1);
+ std::memcpy(argv_copy, argv, sizeof(char*) * argc);
+ argv_copy[argc] = nullptr;
+ return argv_copy;
+}