Skip to content

Commit 331fb13

Browse files
committed
broker: always execute rc2 in a separate process group
Problem: The broker may execute rc2 (the intiial program) using either runat_push_shell_command() (if there is only 1 argument), or runat_push_command() (if there are multiple arguments). However, runat_push_shell_command() runs processes in their own process group, while runat_push_command() does not. This causes different behavior in signal handling between different batch jobs depending on the number of arguments: i.e. in one case, signals sent to the batch job are delivered to the batch script, and in the other case they are not. This difference makes the behavior of signals unpredictiable for user batch jobs. Add the FLUX_SUBPROCESS_FLAGS_SETPGRP flag in runat_push_command() as it is done in runat_push_shell_command() so that rc2 is always run in its own process group, regardless of the number of args.
1 parent 5948b01 commit 331fb13

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/broker/runat.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,9 @@ int runat_push_shell_command (struct runat *r,
465465

466466
/* For shell commands run the target cmdline in a separate process
467467
* group so that any processes spawned by the shell will be signaled
468-
* in runat_abort(). This is probably unnecessary for single commands,
469-
* and does not work for an interactive shell (seems to disable access
470-
* to the pty), so we set the flag only here for now.
468+
* in runat_abort(). This does not work for an interactive shell
469+
* (seems to disable access to the pty), so this flag is not set in
470+
* runat_push_shell().
471471
*/
472472
cmd->flags |= FLUX_SUBPROCESS_FLAGS_SETPGRP;
473473

@@ -522,6 +522,13 @@ int runat_push_command (struct runat *r,
522522
}
523523
if (!(cmd = runat_command_create (environ, flags)))
524524
return -1;
525+
526+
/* Run the target cmdline in a separate process group so that any
527+
* processes spawned by the new process are also signaled in
528+
* runat_abort().
529+
*/
530+
cmd->flags |= FLUX_SUBPROCESS_FLAGS_SETPGRP;
531+
525532
if (runat_command_set_argz (cmd, argz, argz_len) < 0)
526533
goto error;
527534
if (runat_command_modenv (cmd, env_blocklist, r->local_uri) < 0)

0 commit comments

Comments
 (0)