shutdown(cwd?: string): Promise<boolean>
Sends shutdown and waits until the daemon has actually fully exited — not just
until the socket closes. The daemon's dispatch handler acks 'done' before its
async cleanup (server.close / browser.close / process.exit) runs, so a naive
"stop returned" signal leaves the daemon's socket / named-pipe handle still
held. A fast follow-up daemon start would then race the dying daemon and hit
EADDRINUSE — observed reliably on Windows where named-pipe handle release lags
process exit by tens of milliseconds.
Reads the pid upfront (before sending shutdown — the daemon sync-unlinks the
info file in its dispatch handler, so we can't read it after) and polls
process.kill(pid, 0) until ESRCH. Bounded by SHUTDOWN_PID_WAIT_MS.
Returns true if a daemon was reached and asked to stop, false if no daemon
was running.
import * as Client from './client.ts'; // Defined, not invoked: `qunitx daemon stop` — IPC plus a bounded pid-exit poll. async function stopDaemon() { return await Client.shutdown(); // true if a daemon was reached, false when none was running }