#include <xbt/log.h>
#include <xbt/automaton.h>
#include <xbt/automaton.hpp>
+#include <xbt/system_error.hpp>
#include "simgrid/sg_config.h"
sigemptyset(&set);
sigaddset(&set, SIGCHLD);
if (sigprocmask(SIG_BLOCK, &set, nullptr) == -1)
- throw std::system_error(errno, std::system_category());
+ throw simgrid::xbt::errno_error(errno);
sigset_t full_set;
sigfillset(&full_set);
int signal_fd = signalfd(-1, &set, 0);
if (signal_fd == -1)
- throw std::system_error(errno, std::system_category());
+ throw simgrid::xbt::errno_error(errno);
struct pollfd* signalfd_pollfd = &fds_[SIGNAL_FD_INDEX];
signalfd_pollfd->fd = signal_fd;
{
int res = process.send_message(MC_MESSAGE_CONTINUE);
if (res)
- throw std::system_error(res, std::system_category());
+ throw simgrid::xbt::errno_error(res);
process.cache_flags = (mc_process_cache_flags_t) 0;
}
socklen_t errlen = sizeof(error);
if (getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&error, &errlen) == -1)
error = errno;
- throw std::system_error(error, std::system_category());
+ throw simgrid::xbt::errno_error(errno);
}
bool ModelChecker::handle_message(char* buffer, ssize_t size)
case MC_MESSAGE_ASSERTION_FAILED:
MC_report_assertion_error();
- ::exit(SIMGRID_MC_EXIT_SAFETY);
+ this->exit(SIMGRID_MC_EXIT_SAFETY);
break;
default:
return true;
}
+/** Terminate the model-checker aplication */
+void ModelChecker::exit(int status)
+{
+ // TODO, terminate the model checker politely instead of exiting rudel
+ if (process().running())
+ kill(process().pid(), SIGKILL);
+ ::exit(status);
+}
+
bool ModelChecker::handle_events()
{
char buffer[MC_MESSAGE_LENGTH];
case EINTR:
continue;
default:
- throw std::system_error(errno, std::system_category());
+ throw simgrid::xbt::errno_error(errno);
}
}
if (socket_pollfd->revents & POLLIN) {
ssize_t size = MC_receive_message(socket_pollfd->fd, buffer, sizeof(buffer), MSG_DONTWAIT);
if (size == -1 && errno != EAGAIN)
- throw std::system_error(errno, std::system_category());
+ throw simgrid::xbt::errno_error(errno);
return handle_message(buffer, size);
}
if (socket_pollfd->revents & POLLERR) {
if (errno == EINTR)
continue;
else
- throw std::system_error(errno, std::system_category());
+ throw simgrid::xbt::errno_error(errno);
} else if (size != sizeof(info))
return throw std::runtime_error(
"Bad communication with model-checked application");
break;
} else {
XBT_ERROR("Could not wait for pid");
- throw std::system_error(errno, std::system_category());
+ throw simgrid::xbt::errno_error(errno);
}
}
xbt_die("Could not get exit status");
if (WIFSIGNALED(status)) {
MC_report_crash(status);
- ::exit(SIMGRID_MC_EXIT_PROGRAM_CRASH);
+ mc_model_checker->exit(SIMGRID_MC_EXIT_PROGRAM_CRASH);
}
}