From 1bf67ee23204e242cd92c90033bdba29b99b2eea Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Wed, 6 Nov 2024 14:43:42 +0000 Subject: [PATCH] imp: run: put child in new process group 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. --- src/imp/run.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/imp/run.c b/src/imp/run.c index 06211dd..4b6725a 100644 --- a/src/imp/run.c +++ b/src/imp/run.c @@ -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));