forked from kent/consciousness
improve bail-no-competing.sh
This commit is contained in:
parent
9fc27e7372
commit
c300013ce5
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue