pub fn ensure_running(opts: &DaemonOpts) -> Result<Ensured, EnsureError>Expand description
Attach-path entry: a live daemon or a freshly spawned one (jcode model —
first client spawns via setsid + ready-fd; the daemon holds the flock).
The spawn lock (<stem>.spawn.lock next to the flock) serialises
concurrent first-clients: the loser blocks on it, then re-probes the
flock and finds the winner’s daemon. Enabled warm attaches also acquire
this lock (extra open/flock overhead, and the lock must be writable).
Never touches the socket on ECONNREFUSED alone — reap_stale + the
flock decide. Daemon startup must NOT acquire the spawn lock: its parent
holds it until the child’s ready-fd acknowledgement.