-// static
-Session* Session::fork(std::function<void(void)> code)
-{
- // Create a AF_LOCAL socketpair used for exchanging messages
- // bewteen the model-checker process (ourselves) and the model-checked
- // process:
- int res;
- int sockets[2];
- res = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, sockets);
- if (res == -1)
- throw simgrid::xbt::errno_error("Could not create socketpair");
-
- pid_t pid = do_fork([&] {
- ::close(sockets[1]);
- setup_child_environment(sockets[0]);
- code();
- xbt_die("The model-checked process failed to exec()");
- });
-
- // Parent (model-checker):
- ::close(sockets[0]);
-
- return new Session(pid, sockets[1]);
-}
-
-// static
-Session* Session::spawnv(const char *path, char *const argv[])
-{
- return Session::fork([&] {
- execv(path, argv);
- });
-}
-
-// static
-Session* Session::spawnvp(const char *path, char *const argv[])
-{
- return Session::fork([&] {
- execvp(path, argv);
- });
-}
-