probePidAlive function

bool? probePidAlive(
  1. int pid
)

Whether pid is still a live process, or null when this host has no probe (Windows — Process.killPid there hard-terminates regardless of signal, so it can never act as a liveness check).

A false answer is definitive (no such process — the owner of a presence file is gone); null means "unknown" and callers fall back to time-based staleness. Errors (spawn failures, odd shells) degrade to null the same way — the sweep must never turn a probe hiccup into a wrong deletion.

Implementation

bool? probePidAlive(int pid) {
  if (!Platform.isLinux && !Platform.isMacOS) return null;
  try {
    return Process.runSync('kill', ['-0', '$pid']).exitCode == 0;
  } on Object {
    return null;
  }
}