- 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");