terminateDaemon stops the daemon on Windows. Windows has no SIGTERM, so it terminates with Kill — but only after confirming proc is actually this repo's watch daemon. Ownership is checked against proc.Pid (not by re-reading watch.pid) so we validate the exact process we are about to kill. A stale wa
(root string, proc *os.Process)
| 54 | // watch.pid may point to a PID the OS reused for an unrelated process; killing |
| 55 | // that would be destructive, so we refuse when ownership is foreign or unknown. |
| 56 | func terminateDaemon(root string, proc *os.Process) error { |
| 57 | switch daemonOwnershipForPID(root, proc.Pid) { |
| 58 | case ownershipOwned: |
| 59 | return proc.Kill() |
| 60 | case ownershipForeign: |
| 61 | return ErrForeignDaemonPID |
| 62 | default: |
| 63 | return ErrDaemonOwnershipUnknown |
| 64 | } |
| 65 | } |
nothing calls this directly
no test coverage detected