improve bail-no-competing.sh

This commit is contained in:
Kent Overstreet 2026-04-11 18:41:44 -04:00
parent 9fc27e7372
commit c300013ce5

View file

@ -10,7 +10,13 @@ shopt -s nullglob
my_pid_file="$1"
for f in pid-*; do
[[ $f != $my_pid_file ]] && exit 1
[[ $f == $my_pid_file ]] && continue
pid="${f#pid-}"
if kill -0 "$pid" 2>/dev/null; then
exit 1 # competing agent is alive
else
rm -f "$f" # stale pid file, clean up
fi
done
exit 0