Context
bashunit::runner::wait_for_job_slot (src/runner.sh:136-160) polls jobs -r | wc -l with adaptive 50ms→200ms sleep to detect free slots. Each poll forks a subshell for jobs -r | wc -l and adds wakeup latency on test completion.
Proposal
When Bash >= 4.3 (supports wait -n), block on next-child-exit instead of polling:
if [ "\${BASH_VERSINFO[0]}" -gt 4 ] || { [ "\${BASH_VERSINFO[0]}" -eq 4 ] && [ "\${BASH_VERSINFO[1]}" -ge 3 ]; }; then
while [ "\$(jobs -r | wc -l)" -ge "\$max_jobs" ]; do
wait -n 2>/dev/null || break
done
else
# existing poll loop (Bash 3.0 fallback)
fi
Eliminates sleep latency and reduces jobs -r invocations.
Acceptance
Context
bashunit::runner::wait_for_job_slot(src/runner.sh:136-160) pollsjobs -r | wc -lwith adaptive 50ms→200mssleepto detect free slots. Each poll forks a subshell forjobs -r | wc -land adds wakeup latency on test completion.Proposal
When Bash >= 4.3 (supports
wait -n), block on next-child-exit instead of polling:Eliminates sleep latency and reduces
jobs -rinvocations.Acceptance
wait -npath used on Bash 4.3+