@@ -253,12 +253,18 @@ _test_gate_run_units() {
253253 # 100%+ CPU each, run twice per commit-phase attempt (HEAD + baseline),
254254 # with up to MAX_CONCURRENT deliveries in parallel — background test
255255 # execution otherwise competes evenly with the operator's foreground work
256- # for CPU scheduling. renice on $$ (this subshell) before spawning the
257- # test process; child processes inherit the lowered niceness. macOS/Linux
258- # still grant it idle CPU when nothing else needs it, so total suite
259- # wall-clock is not meaningfully affected — only scheduling priority
260- # under contention changes.
261- (renice -n 15 -p $$ > /dev/null 2>&1 ; cd " $worktree_path " && eval " $cmd " ) 2>&1 | tee -a /dev/stderr > /dev/null
256+ # for CPU scheduling. Renice THIS subshell before spawning the test
257+ # process so its children inherit the lowered niceness — must target
258+ # $BASHPID, not $$: inside `( ... )`, $$ still resolves to the PARENT
259+ # shell's PID (bash never rebinds it for subshells), so `renice -p $$`
260+ # relabels a process that already forked this subshell before the call
261+ # ran and has no effect on anything forked from here. Verified: children
262+ # spawned after `renice -p $$` stayed at nice 0; after `renice -p
263+ # $BASHPID` they correctly inherit 15. macOS/Linux still grant idle CPU
264+ # when nothing else needs it, so total suite wall-clock is not
265+ # meaningfully affected — only scheduling priority under contention
266+ # changes.
267+ (renice -n 15 -p $BASHPID > /dev/null 2>&1 ; cd " $worktree_path " && eval " $cmd " ) 2>&1 | tee -a /dev/stderr > /dev/null
262268 exit_code=${PIPESTATUS[0]}
263269 echo " [TEST-GATE] unit=${label} type=${type} exit=${exit_code} " >&2
264270
0 commit comments