xbt_die("SimGrid was compiled without MC support.");
#endif
} else {
- master_socket_ = socket(AF_LOCAL, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
+ master_socket_ = socket(AF_LOCAL,
+ SOCK_SEQPACKET
+#ifdef SOCK_CLOEXEC
+ | SOCK_CLOEXEC /* MacOSX does not have it */
+#endif
+ ,
+ 0);
xbt_assert(master_socket_ != -1, "Cannot create the master socket: %s", strerror(errno));
struct sockaddr_un serv_addr = {};
xbt_assert(pid >= 0, "Could not fork application sub-process: %s.", strerror(errno));
if (pid == 0) { // Child
- int sock = socket(AF_LOCAL, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
+ int sock = socket(AF_LOCAL,
+ SOCK_SEQPACKET
+#ifdef SOCK_CLOEXEC
+ | SOCK_CLOEXEC /* MacOSX does not have it */
+#endif
+ ,
+ 0);
struct sockaddr_un addr = {};
addr.sun_family = AF_LOCAL;
xbt_assert(prctl(PR_SET_PDEATHSIG, SIGHUP) == 0, "Could not PR_SET_PDEATHSIG");
#endif
- // Remove CLOEXEC to pass the socket to the application
- int fdflags = fcntl(socket, F_GETFD, 0);
- xbt_assert(fdflags != -1 && fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) != -1,
- "Could not remove CLOEXEC for socket");
-
setenv(MC_ENV_SOCKET_FD, std::to_string(socket).c_str(), 1);
if (need_ptrace)
setenv("MC_NEED_PTRACE", "1", 1);
// Create an AF_LOCAL socketpair used for exchanging messages between the model-checker process (ancestor)
// and the application process (child)
int sockets[2];
- xbt_assert(socketpair(AF_LOCAL, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sockets) != -1, "Could not create socketpair: %s",
+ xbt_assert(socketpair(AF_LOCAL, SOCK_SEQPACKET, 0, sockets) != -1, "Could not create socketpair: %s",
strerror(errno));
pid_ = fork();