#endif
#include <xbt/log.h>
+#include <xbt/sysdep.h>
+#include <xbt/system_error.hpp>
#include "simgrid/sg_config.h"
#include "src/xbt_modinter.h"
{
pid_t pid = fork();
if (pid < 0)
- throw new std::system_error(errno, std::generic_category());
+ throw simgrid::xbt::errno_error(errno, "Could not fork model-checked process");
if (pid != 0)
return pid;
sigset_t mask;
sigemptyset (&mask);
if (sigprocmask(SIG_SETMASK, &mask, nullptr) < 0)
- throw new std::system_error(errno, std::generic_category(), "sigprocmask");
+ throw simgrid::xbt::errno_error(errno, "Could not unblock signals");
if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0)
- throw new std::system_error(errno, std::generic_category(), "PR_SET_PDEATHSIG");
+ throw simgrid::xbt::errno_error(errno, "Could not PR_SET_PDEATHSIG");
#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)
- throw new std::system_error(errno, std::generic_category(), "F_GETFD");
- if (fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) == -1)
- throw new std::system_error(errno, std::generic_category(), "Remove FD_CLOEXEC");
+ if (fdflags == -1 || fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) == -1)
+ throw simgrid::xbt::errno_error(errno, "Could not remove CLOEXEC for socket");
// Set environment:
setenv(MC_ENV_VARIABLE, "1", 1);
int sockets[2];
res = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, sockets);
if (res == -1)
- throw new std::system_error(errno, std::generic_category(), "socketpair");
+ throw simgrid::xbt::errno_error(errno, "Could not create socketpair");
pid_t pid = do_fork([&] {
close(sockets[1]);
{
char** argv_copy = xbt_new(char*, argc+1);
std::memcpy(argv_copy, argv, sizeof(char*) * argc);
- argv_copy[argc] = NULL;
+ argv_copy[argc] = nullptr;
return argv_copy;
}