Skip to content

Background jobs and pipeline stages run concurrently

Changelog

Improvement BashkitCode

On main, not yet released

cmd & now runs concurrently with the shell, so sleep 1 & sleep 1 & wait takes one second instead of two. New jobs, disown, fg, bg, ps, pgrep and pkill builtins, wait -n, wait -p VAR and jobspecs work, and kill ends jobs. Live jobs are capped by ExecutionLimits::max_background_jobs.

Pipeline stages that run shell code, such as loops, groups and functions, now stream into each other through a pipe with backpressure. When a reader stops, the writer gets SIGPIPE and exits with 141, so while :; do echo x; done | head -n 2 prints two lines as in bash.

Both are on by default; BashBuilder::concurrent_jobs(false) turns them off.

See the compatibility scorecard, #2527 and #2541.