From: adfaure Date: Mon, 6 Jun 2016 12:55:35 +0000 (+0200) Subject: [s4u] add kill actor with its PID X-Git-Tag: v3_14~1052 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/a7e7f3ed5bfa913f435675626e135df45db90867 [s4u] add kill actor with its PID --- diff --git a/include/simgrid/s4u/actor.hpp b/include/simgrid/s4u/actor.hpp index fd818b7454..3e2ce5b86a 100644 --- a/include/simgrid/s4u/actor.hpp +++ b/include/simgrid/s4u/actor.hpp @@ -6,6 +6,7 @@ #ifndef SIMGRID_S4U_ACTOR_HPP #define SIMGRID_S4U_ACTOR_HPP +#include #include #include #include @@ -74,6 +75,8 @@ public: */ void kill(); + static void kill(int PID); + // Static methods on all actors: /** Ask kindly to all actors to die. Only the issuer will survive. */ diff --git a/src/s4u/s4u_actor.cpp b/src/s4u/s4u_actor.cpp index a220c8ce69..6c2f29c8bd 100644 --- a/src/s4u/s4u_actor.cpp +++ b/src/s4u/s4u_actor.cpp @@ -53,6 +53,17 @@ double s4u::Actor::getKillTime() { return simcall_process_get_kill_time(pimpl_); } +void s4u::Actor::kill(int PID) { + msg_process_t process = SIMIX_process_from_PID(PID); + if(process != NULL) { + simcall_process_kill(process); + } else { + std::ostringstream oss; + oss << "kill: ("<< PID <<") - No such process" << std::endl; + throw std::runtime_error(oss.str()); + } +} + void s4u::Actor::kill() { simcall_process_kill(pimpl_); }