Bash — Parallel Pipeline with Exit Code Aggregation
Parallelize a serial pipeline while correctly capturing every child exit code.
A advanced Linux challenge worth 20 points. Solve it hands-on in a real Linux environment in your browser - no local setup, no fake shells.
The Challenge
A nightly pipeline runs 8 scripts at /opt/pipeline/job-{1..8}.sh serially. A previous parallel attempt silently swallowed failures. You must parallelize correctly.
Write /opt/pipeline/run-parallel.sh that:
- Launches all 8 scripts with & and stores each PID: pids+=($!)
- Waits for each PID and collects exit code: wait $pid; codes+=($?)
- Traps SIGINT/SIGTERM to kill background jobs
- Exits with 1 if any code is non-zero, 0 if all pass
- Writes a report to /tmp/pipeline_report.txt: each job name and PASS/FAIL
Make it executable: chmod +x /opt/pipeline/run-parallel.sh Run it and verify the correct exit code and report. Run check to validate.