MCPcopy Create free account
hub / github.com/JordanCoin/codemap / terminateDaemon

Function terminateDaemon

watch/process_windows.go:56–65  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
56func 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}

Callers

nothing calls this directly

Calls 1

daemonOwnershipForPIDFunction · 0.85

Tested by

no test coverage detected