Skip to content

Make watch stop work safely on Windows (PID-ownership verification) #74

Description

@JordanCoin

Follow-up from #73 / #72.

#73 fixes watch status on Windows (via a platform-specific processAlive). It intentionally leaves watch stop non-destructive on Windows (SIGTERM is unsupported, so it returns an error without killing).

Making Windows stop actually terminate the daemon requires guarding against PID reuse: a stale .codemap/watch.pid may point to a PID the OS has reassigned to an unrelated process, and blindly Kill-ing it would terminate the wrong process (P2 raised by Codex on #73).

Work

  • Implement processCommandLine on Windows (currently a stub) — e.g. via Get-CimInstance Win32_Process / QueryFullProcessImageName — so IsOwnedDaemon can verify the PID is a codemap watch daemon <root> for this repo.
  • Gate the Windows stop/kill path on that ownership check; refuse (with a clear message) when ownership can't be established.
  • Consider applying the same ownership guard to the Unix stop path for consistency.

Acceptance

  • codemap watch stop terminates a real daemon on Windows.
  • A stale watch.pid whose PID was reused does not get killed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions