Skip to content

Commit

Permalink
imp: run: put child in new process group
Browse files Browse the repository at this point in the history
Problem: Before the removal of `flux-imp kill`, commands invoked by
`flux-imp run` were signaled by process group instead of an individual
process ID. This worked well because `flux-imp run` replaced itself
with the target command, and thus the command and its children were
in a process group (set up by flux-core's libsubprocess). Now, the
IMP itself will be in that process group, and if it tries to forward
signals to the entire process group it will end up re-signaling itself.

Call `setpgrp(2)` in the child to place it in its own process group.
The IMP now has a process group to which it can forward signals.
  • Loading branch information
grondo committed Nov 6, 2024
1 parent 2bc769d commit 1bf67ee
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/imp/run.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ imp_run (struct imp_state *imp,
/* unblock all signals */
imp_sigunblock_all ();

/* Place child in its own process group, so that parent IMP
* can signal the pgrp as a whole
*/
if (setpgrp () < 0)
imp_die (1, "setpgrp: %s", strerror (errno));

if (setuid (geteuid()) < 0
|| setgid (getegid()) < 0)
imp_die (1, "setuid: %s", strerror (errno));
Expand Down

0 comments on commit 1bf67ee

Please sign in to comment.