- if (pid == this->process().pid()) {
- xbt_assert(WIFEXITED(status) || WIFSIGNALED(status));
- XBT_DEBUG("Child process is over");
- this->process().terminate();
+ if (pid == this->get_remote_simulation().pid()) {
+ // From PTRACE_O_TRACEEXIT:
+#ifdef __linux__
+ if (status>>8 == (SIGTRAP | (PTRACE_EVENT_EXIT<<8))) {
+ xbt_assert(ptrace(PTRACE_GETEVENTMSG, remote_simulation_->pid(), 0, &status) != -1,
+ "Could not get exit status");
+ if (WIFSIGNALED(status)) {
+ MC_report_crash(status);
+ mc_model_checker->exit(SIMGRID_MC_EXIT_PROGRAM_CRASH);
+ }
+ }
+#endif
+
+ // We don't care about signals, just reinject them:
+ if (WIFSTOPPED(status)) {
+ XBT_DEBUG("Stopped with signal %i", (int) WSTOPSIG(status));
+ errno = 0;
+#ifdef __linux__
+ ptrace(PTRACE_CONT, remote_simulation_->pid(), 0, WSTOPSIG(status));
+#elif defined BSD
+ ptrace(PT_CONTINUE, remote_simulation_->pid(), (caddr_t)1, WSTOPSIG(status));
+#endif
+ xbt_assert(errno == 0, "Could not PTRACE_CONT");
+ }
+
+ else if (WIFSIGNALED(status)) {
+ MC_report_crash(status);
+ mc_model_checker->exit(SIMGRID_MC_EXIT_PROGRAM_CRASH);
+ } else if (WIFEXITED(status)) {
+ XBT_DEBUG("Child process is over");
+ this->get_remote_simulation().terminate();
+ }