pub fn write_self_role_pid(role: &str) -> Result<()>Expand description
Long-running-role startup: claim the <role>.pid file for THIS
process inside the active WIRE_HOME. Same on-disk JSON shape as
daemon.pid, just keyed by role.
#247 finding 4: the per-role pidfile is what lets the cross-platform
identity-collision check map another wire process’s PID back to the
WIRE_HOME it serves. Windows has no portable way to read another
process’s environment, so the env-based POSIX path
(/proc/<pid>/environ / ps -E) doesn’t translate — but every
inbox-owning long-running role (daemon / mcp / monitor / notify)
living under <WIRE_HOME>/state/wire/<role>.pid IS a portable
signal: a Windows waiter walks list_sessions() × roles, matches
the candidate PID against each pidfile, and reads off the session’s
home. The POSIX path keeps its env-based fast path; this gives
Windows the same coverage without an NtQueryInformationProcess
FFI dep.
Idempotent: if the pidfile already records our PID we leave it alone.