diff --git a/src/mca/pcm/rsh/pcm_rsh_kill.c b/src/mca/pcm/rsh/pcm_rsh_kill.c index a23eaccd22..3f9d24869d 100644 --- a/src/mca/pcm/rsh/pcm_rsh_kill.c +++ b/src/mca/pcm/rsh/pcm_rsh_kill.c @@ -6,27 +6,60 @@ #include "ompi_config.h" +#include +#include +#include + #include "pcm_rsh.h" #include "include/constants.h" +#include "runtime/runtime.h" #include "mca/pcm/pcm.h" #include "mca/pcm/base/base_job_track.h" int -mca_pcm_rsh_kill_proc(struct mca_pcm_base_module_1_0_0_t* me, +mca_pcm_rsh_kill_proc(struct mca_pcm_base_module_1_0_0_t* me_super, ompi_process_name_t *name, int flags) { - return OMPI_ERROR; + pid_t pid; + mca_pcm_rsh_module_t *me = (mca_pcm_rsh_module_t*) me_super; + + if (0 != (OMPI_RTE_SPAWN_HIGH_QOS &me->constraints)) { + pid = mca_pcm_base_get_started_pid(ns_base_get_jobid(name), + ns_base_get_vpid(name), + false); + if (pid <= 0) return errno; + + kill(pid, SIGTERM); + } else { + return OMPI_ERR_NOT_IMPLEMENTED; + } + + return OMPI_SUCCESS; } int -mca_pcm_rsh_kill_job(struct mca_pcm_base_module_1_0_0_t* me, +mca_pcm_rsh_kill_job(struct mca_pcm_base_module_1_0_0_t* me_super, mca_ns_base_jobid_t jobid, int flags) { - /* BWB - do stuff */ - - mca_pcm_base_remove_job(jobid); + pid_t *pids; + size_t pids_len, i; + int ret; + mca_pcm_rsh_module_t *me = (mca_pcm_rsh_module_t*) me_super; - return OMPI_ERROR; + if (0 != (OMPI_RTE_SPAWN_HIGH_QOS &me->constraints)) { + ret = mca_pcm_base_get_started_pid_list(jobid, &pids, + &pids_len, false); + if (ret != OMPI_SUCCESS) return ret; + + for (i = 0 ; i < pids_len ; ++i) { + kill(pids[i], SIGTERM); + } + + } else { + return OMPI_ERR_NOT_IMPLEMENTED; + } + + return OMPI_SUCCESS; } diff --git a/src/mca/pcm/rsh/pcm_rsh_spawn.c b/src/mca/pcm/rsh/pcm_rsh_spawn.c index 6fbf06571e..1a41574c72 100644 --- a/src/mca/pcm/rsh/pcm_rsh_spawn.c +++ b/src/mca/pcm/rsh/pcm_rsh_spawn.c @@ -493,4 +493,7 @@ internal_wait_cb(pid_t pid, int status, void *data) ompi_registry.rte_unregister(test); } #endif + + /* bwb - fix me - should only remove this range */ + mca_pcm_base_remove_job(jobid); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 3cb5ab6be7..362379a877 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -24,10 +24,31 @@ #include "mpi/runtime/mpiruntime.h" /* constants for spawn constraints */ + +/** Spawn constraint - require multi-cell support. The selected spawn + system must be capable of starting across multiple cells. This + allows multiple pcms to be used to satisfy a single resource + allocation request */ #define OMPI_RTE_SPAWN_MULTI_CELL 0x0001 +/** Spawn constraint - require ability to launch daemons. The + selected spawn system must be capable of starting daemon process. + Setting this flag will result in a spawn service that does not + provide process monitoring or standard I/O forwarding. The caller + may exit before all children are cleaned up, but + OMPI_RTE_SPAWN_EARLY_EXIT is not implied because there is no + expectation of process monitoring. */ #define OMPI_RTE_SPAWN_DAEMON 0x0002 +/** Spawn constraint - require quality of service support. The + selected spawn system must provide I/O forwarding, quick process + shutdown, and process status monitoring. */ #define OMPI_RTE_SPAWN_HIGH_QOS 0x0004 -#define OMPI_RTE_SPAWN_FROM_MPI 0x0008 +/** Spawn constraint - caller is an MPI process. The caller is an MPI + application (has called MPI_Init). Implies + OMPI_RTE_SPAWN_EARLY_EXIT */ +#define OMPI_RTE_SPAWN_FROM_MPI 0x0018 +/** Spawn constraint - caller may exit before child. The caller may + exit before children have exited. */ +#define OMPI_RTE_SPAWN_EARLY_EXIT 0x0010 #ifdef __cplusplus extern "C" {