Skip to content

Commit 501ba8f

Browse files
author
Ralph Castain
authored
Merge pull request #3704 from rhc54/topic/signal
Control distribution of signals to children vs grandchildren
2 parents 814e858 + 206aec6 commit 501ba8f

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

orte/mca/odls/base/odls_base_frame.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ static int orte_odls_base_register(mca_base_register_flag_t flags)
8686
MCA_BASE_VAR_SCOPE_READONLY,
8787
&orte_odls_globals.num_threads);
8888

89+
orte_odls_globals.signal_direct_children_only = false;
90+
(void) mca_base_var_register("orte", "odls", "base", "signal_direct_children_only",
91+
"Whether to restrict signals (e.g., SIGTERM) to direct children, or "
92+
"to apply them as well to any children spawned by those processes",
93+
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
94+
OPAL_INFO_LVL_9,
95+
MCA_BASE_VAR_SCOPE_READONLY,
96+
&orte_odls_globals.signal_direct_children_only);
97+
8998
return ORTE_SUCCESS;
9099
}
91100

orte/mca/odls/base/odls_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef struct {
6262
opal_event_base_t **ev_bases; // event base array for progress threads
6363
char** ev_threads; // event progress thread names
6464
int next_base; // counter to load-level thread use
65+
bool signal_direct_children_only;
6566
} orte_odls_globals_t;
6667

6768
ORTE_DECLSPEC extern orte_odls_globals_t orte_odls_globals;

orte/mca/odls/default/odls_default_module.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,22 @@ int orte_odls_default_launch_local_procs(opal_buffer_t *data)
644644
* Send a signal to a pid. Note that if we get an error, we set the
645645
* return value and let the upper layer print out the message.
646646
*/
647-
static int send_signal(pid_t pid, int signal)
647+
static int send_signal(pid_t pd, int signal)
648648
{
649649
int rc = ORTE_SUCCESS;
650+
pid_t pid;
651+
652+
if (orte_odls_globals.signal_direct_children_only) {
653+
pid = pd;
654+
} else {
655+
#if HAVE_SETPGID
656+
/* send to the process group so that any children of our children
657+
* also receive the signal*/
658+
pid = -pd;
659+
#else
660+
pid = pd;
661+
#endif
662+
}
650663

651664
OPAL_OUTPUT_VERBOSE((1, orte_odls_base_framework.framework_output,
652665
"%s sending signal %d to pid %ld",

0 commit comments

Comments
 (0)