JNIEXPORT void JNICALL Java_org_simgrid_msg_Process_waitFor(JNIEnv * env, jobject jprocess, jdouble jseconds)
{
- msg_error_t rv;
+ msg_error_t rv = MSG_OK;
if (not simgrid::kernel::context::StopRequest::try_n_catch(
- [&rv, &jseconds]() { rv = MSG_process_sleep((double)jseconds); })) {
+ [&jseconds]() { simgrid::s4u::this_actor::sleep_for((double)jseconds); })) {
+ rv = MSG_HOST_FAILURE;
jxbt_throw_by_name(env, "org/simgrid/msg/ProcessKilledError", "Process killed");
}
if (env->ExceptionOccurred())
msg_task_t task = MSG_task_create("COMM", 0, 100000000, NULL);
MSG_task_dsend(task, mailbox, task_cleanup_handler);
// We should wait a bit (if not the process will end before the communication, hence an exception on the other side).
- int res = MSG_process_sleep(30);
- if (res == MSG_HOST_FAILURE) {
+ try {
+ MSG_process_sleep(30);
+ } catch (simgrid::HostFailureException& e) {
XBT_INFO("The host has died ... as expected.");
}
XBT_INFO(" TX done");