+void AppSide::handle_fork(const s_mc_message_int_t* msg)
+{
+ int pid = fork();
+ 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);
+
+ struct sockaddr_un addr = {};
+ addr.sun_family = AF_LOCAL;
+ snprintf(addr.sun_path, 64, "/tmp/simgrid-mc-%lu", msg->value);
+ auto addr_size = offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path);
+
+ xbt_assert(connect(sock, (struct sockaddr*)&addr, addr_size) >= 0,
+ "Cannot connect to Checker on /tmp/simgrid-mc-%lu: %s.", msg->value, strerror(errno));
+
+ channel_.reset_socket(sock);
+
+ s_mc_message_int_t answer = {};
+ answer.type = MessageType::FORK_REPLY;
+ answer.value = getpid();
+ xbt_assert(channel_.send(answer) == 0, "Could not send response to WAIT_CHILD_REPLY: %s", strerror(errno));
+ }
+}
+void AppSide::handle_wait_child(const s_mc_message_int_t* msg)
+{
+ int status;
+ errno = 0;
+ waitpid(msg->value, &status, 0);
+ xbt_assert(errno == 0, "Cannot wait on behalf of the checker: %s.", strerror(errno));
+
+ s_mc_message_int_t answer = {};
+ answer.type = MessageType::WAIT_CHILD_REPLY;
+ answer.value = status;
+ xbt_assert(channel_.send(answer) == 0, "Could not send response to WAIT_CHILD: %s", strerror(errno));
+}