consciousness/src/subconscious/agents/bail-no-competing.sh
ProofOfConcept 5d803441c9 cleanup: kill dead code, fix signal handler safety
- Remove unused now_secs(), parse_json_response, any_alive, Regex import
- Signal handler: replace Mutex with AtomicPtr<c_char> for signal safety
  (Mutex::lock in a signal handler can deadlock if main thread holds it)
- PidGuard Drop reclaims the leaked CString; signal handler just unlinks
- scan_pid_files moved to knowledge.rs as pub helper
- setup_agent_state calls scan_pid_files to clean stale pids on startup

Co-Authored-By: Kent Overstreet <kent.overstreet@linux.dev>
2026-03-26 15:58:59 -04:00

14 lines
257 B
Bash
Executable file

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