From 0e9457d2a9f012e1a6af0ffdb6044b6191283df9 Mon Sep 17 00:00:00 2001 From: Hui Zhou Date: Tue, 9 Jul 2024 10:39:09 -0500 Subject: [PATCH] hydra/proxy: prevent double resetting exit_status Under the default auto_cleanup mode, when one process exit abnormally, hydra will kill all other processes by pre-setting the exit_status to 0. Sometimes two or more processes exit abnormally before the latter one being killed. This resulting in double presetting the exit status which resulted in all exit code for all processes being 0. --- src/pm/hydra/proxy/pmip_cb.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/pm/hydra/proxy/pmip_cb.c b/src/pm/hydra/proxy/pmip_cb.c index dd4b2d99faa..2a209a776d3 100644 --- a/src/pm/hydra/proxy/pmip_cb.c +++ b/src/pm/hydra/proxy/pmip_cb.c @@ -312,16 +312,19 @@ static HYD_status pmi_cb(int fd, HYD_event_t events, void *userp) close(fd); if (HYD_pmcd_pmip.user_global.auto_cleanup) { - /* kill all processes */ - /* preset all exit_status except for the closed pid */ - struct pmip_pg *pg = PMIP_pg_from_downstream(p); - for (int i = 0; i < pg->num_procs; i++) { - if (p != &pg->downstreams[i] && - pg->downstreams[i].exit_status == PMIP_EXIT_STATUS_UNSET) { - pg->downstreams[i].exit_status = 0; + /* if exit_status has been set, the kill signals bcast'ed already */ + if (p->exit_status == PMIP_EXIT_STATUS_UNSET) { + /* kill all processes */ + /* preset all exit_status except for the closed pid */ + struct pmip_pg *pg = PMIP_pg_from_downstream(p); + for (int i = 0; i < pg->num_procs; i++) { + if (p != &pg->downstreams[i] && + pg->downstreams[i].exit_status == PMIP_EXIT_STATUS_UNSET) { + pg->downstreams[i].exit_status = 0; + } } + PMIP_bcast_signal(SIGKILL); } - PMIP_bcast_signal(SIGKILL); } else { /* If the user doesn't want to automatically cleanup, * signal the remaining processes, and send this