Last active
January 7, 2025 16:45
-
-
Save ThinaticSystem/9229605d12f075e0751de3de4746d765 to your computer and use it in GitHub Desktop.
複数コマンドの並行実行 w/ 失敗時の実行中プロセス後片付け (Bash)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
on_some_job_error() { | |
kill "$(jobs -pr)" | |
exit 1 | |
} | |
trap 'on_some_job_error' ERR | |
command1 & | |
command2 & | |
wait | |
echo 'All commands success' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment