Harden companion Windows lifecycle coverage

This commit is contained in:
Drew Ritter
2026-06-10 16:23:13 -07:00
parent 7b757c6de6
commit d47489f9d0
8 changed files with 223 additions and 30 deletions

View File

@@ -20,7 +20,12 @@ PID_FILE="${STATE_DIR}/server.pid"
# not a reused/unrelated process whose PID was recycled into a stale pid file.
is_brainstorm_server() {
kill -0 "$1" 2>/dev/null || return 1
case "$(ps -p "$1" -o command= 2>/dev/null)" in
local command_line
command_line="$(ps -p "$1" -o command= 2>/dev/null || true)"
if [[ -z "$command_line" ]]; then
command_line="$(ps -f -p "$1" 2>/dev/null | sed '1d' || true)"
fi
case "$command_line" in
*node*server.cjs*) ;;
*) return 1 ;;
esac