flux-core icon indicating copy to clipboard operation
flux-core copied to clipboard

libsubprocess: invert SETPGRP flag logic

Open chu11 opened this issue 1 year ago • 1 comments

Problem: Remote subprocesses default to always set the SETPGRP flag. This leads to inconsistent behavior where local subprocesses don't have the flag set but remote ones do.

We could remove this default and require remote subprocess execution to set this flag as needed. However, it ends up that the vast majority of code in flux-core sets the SETPGRP flag anyways, leading to an excess amount of code change to make local vs remote subprocesses consistent.

Solution: Invert the SETPGRP flag logic into NO_SETPGRP. Now, by default, have both local and remote subprocesses call setpgrp(2). The NO_SETPGRP flag will then disable the call to setpgrp(2). Update all callers to libsubprocess accordingly.

Note that we leave the new NO_SETPGRP flag to be for local subprocesses only. If there comes a time for it to be supported for remote subprocesses, that will be for another day.

chu11 avatar Jul 04 '24 21:07 chu11

We could remove this default and require remote subprocess execution to set this flag as needed. However, it ends up that the vast majority of code in flux-core sets the SETPGRP flag anyways, leading to an excess amount of code change to make local vs remote subprocesses consistent.

API wise, NO_SETPGRP seems vaguely wrong to me, but I see where you're coming from about updating all the tests n stuff. @grondo any thoughts?

garlick avatar Oct 09 '24 22:10 garlick

API wise, NO_SETPGRP seems vaguely wrong to me, but I see where you're coming from about updating all the tests n stuff. @grondo any thoughts?

Updating everything to set the SETPGRP flag is certainly ok and fine too, we could do that.

It's mostly to get this consistent, b/c the follow up will be to allow subprocess flags to be passed to remote subprocesses.

chu11 avatar Oct 09 '24 22:10 chu11

Yeah, I was struggling with NO_SETPGRP too, but the simplicity is indeed appealing. I think this PR is probably fine as is.

grondo avatar Oct 10 '24 21:10 grondo

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 83.30%. Comparing base (7cf4359) to head (9fe507b). Report is 465 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6082      +/-   ##
==========================================
- Coverage   83.31%   83.30%   -0.02%     
==========================================
  Files         523      523              
  Lines       86194    86199       +5     
==========================================
- Hits        71811    71806       -5     
- Misses      14383    14393      +10     
Files with missing lines Coverage Δ
src/broker/runat.c 79.13% <ø> (-0.07%) :arrow_down:
src/cmd/builtin/proxy.c 78.24% <100.00%> (+0.30%) :arrow_up:
src/cmd/flux-start.c 83.74% <100.00%> (+0.08%) :arrow_up:
src/common/libsubprocess/fork.c 76.74% <100.00%> (+1.55%) :arrow_up:
src/common/libsubprocess/posix_spawn.c 88.40% <100.00%> (ø)
src/common/libsubprocess/server.c 78.73% <100.00%> (ø)
src/common/libsubprocess/subprocess.c 88.90% <100.00%> (ø)
src/shell/task.c 82.03% <100.00%> (ø)

... and 7 files with indirect coverage changes

codecov[bot] avatar Jan 08 '25 21:01 codecov[bot]