consciousness/src/subconscious/agents/bail-no-competing.sh

17 lines
278 B
Bash
Raw Normal View History

#!/bin/bash
# Bail if other agents are alive in the state dir.
# $1 = this agent's pid file name (e.g. pid-12345)
# cwd = state dir
#
# Exit 0 = continue, exit 1 = bail
shopt -s nullglob
my_pid_file="$1"
for f in pid-*; do
[[ $f != $my_pid_file ]] && exit 1
done
exit 0