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>
This commit is contained in:
ProofOfConcept 2026-03-26 15:58:59 -04:00
parent 52703b4637
commit 5d803441c9
5 changed files with 223 additions and 215 deletions

View file

@ -8,15 +8,7 @@
my_pid_file=$(basename "$1")
for f in pid-*; do
[ "$f" = "$my_pid_file" ] && continue
[ ! -f "$f" ] && continue
pid=${f#pid-}
if kill -0 "$pid" 2>/dev/null; then
exit 1 # another agent is alive, bail
else
rm -f "$f" # stale, clean up
fi
[[ $f != $my_pid_file ]] && exit 1
done
exit 0