Skip to content

feat(backend): portable process identity for Windows - #51

Closed
loss-and-quick wants to merge 2 commits into
mainfrom
feat/windows-proc-identity
Closed

feat(backend): portable process identity for Windows#51
loss-and-quick wants to merge 2 commits into
mainfrom
feat/windows-proc-identity

Conversation

@loss-and-quick

Copy link
Copy Markdown
Owner

Summary

First step of bringing Windows back as a desktop target (it was dropped because the
backend was POSIX-only). This PR makes the neutral backend build on Windows by
porting the one OS-specific piece — process identity in crates/kasumi-backend/src/proc.rs.

proc.rs was POSIX-only: it matched a pid by /proc/<pid>/exe dev/ino and terminated
via libc::kill. The OS-specific half now lives in a cfg-gated imp module:

  • POSIX keeps the /proc inode match + SIGTERM→SIGKILL graceful teardown.
  • Windows matches a pid by its full image path (QueryFullProcessImageNameW) and
    ends it with TerminateProcess. There is no SIGTERM, but the wintun driver reclaims a
    core's tun adapter on process exit, so the hard kill stays clean for a graceful stop.

run/silent/spawn_logged/read_pidfile were already portable and stay shared.
libc moves under cfg(unix); windows-sys (Win32 Threading + Foundation) comes in
under cfg(windows).

The rust CI job runs on Linux and never compiles the #[cfg(windows)] path, so a new
windows-check job clippy-checks the backend on a Windows runner — otherwise the Win32
code would ship unverified. The full src-tauri desktop bundle (tun + routing Platform)
stays Linux-only and is deferred to the next PR.

Affected layer

  • frontend/ — React Web UI
  • module/ — Magisk/KernelSU/APatch payload (shell + packaged kasumi-proxy backend)
  • scripts/ — build / release helpers
  • CI / .github/
  • Docs only

Verification

Rust (nix devshell, Linux):

  • cargo fmt --all --check — clean
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test --workspace — green (proc:: tests pass; shell/proc-only tests gated to unix)
  • codegen drift: cargo run -p kasumi-desktop --bin codegengit diff on frontend/src/generated empty

Windows backend compile is exercised by the new windows-check CI job (clippy on
windows-latest). Local cross-check isn't possible here — the nix toolchain ships only
the host std, no x86_64-pc-windows-msvc std.

Web UI (frontend/): n/a — no frontend change.

Module shell (module/): n/a — no shell change.

Checklist

  • Title is a scoped Conventional Commit; commits are logically split
  • No build artifacts committed
  • If user-visible strings changed: n/a — none changed
  • Renames touching the project id were grepped in all case forms — n/a, no renames

Notes for reviewers

  • Windows pid_matches_bin compares the full image path (no inode on Windows):
    both sides are canonicalized, falling back to a case-insensitive compare when the
    file is no longer openable (process already exited).
  • kill's graceful flag is a no-op on Windows by design — there is no SIGTERM; the
    wintun adapter teardown happens on process exit regardless.
  • Part of the Windows-support series: PR 1/3 (backend) → PR 2 (WindowsPlatform +
    wintun packaging + nightly artifact) → PR 3 (promote to release.yml + README).

proc.rs was POSIX-only: pid matching read /proc/<pid>/exe dev/ino and
termination went through libc::kill. Split the OS-specific half into a
cfg-gated `imp` module so the crate builds on Windows too:

- POSIX keeps the /proc inode match + SIGTERM/SIGKILL teardown.
- Windows matches a pid by its full image path (QueryFullProcessImageNameW)
  and ends it with TerminateProcess; there is no SIGTERM, but the wintun
  driver reclaims a core's adapter on process exit, so the hard kill stays
  clean for a graceful stop.

run/silent/spawn_logged/read_pidfile were already portable and stay shared.
libc moves under cfg(unix); windows-sys (Win32 Threading + Foundation) comes
in under cfg(windows). Shell/proc-dependent unit tests are gated to unix.
The `rust` job runs on Linux and never compiles proc.rs's #[cfg(windows)]
path, so its Win32 code would ship unverified. Add a windows-latest job that
clippy-checks kasumi-backend (cross-platform crates) on a Windows runner,
scoped to crates/ + Cargo changes. Refresh the desktop-linux comment: the
backend now builds on Windows; only the full src-tauri desktop bundle stays
deferred until the Windows Platform port lands.
@loss-and-quick

Copy link
Copy Markdown
Owner Author

Superseded: the work is now one Windows-support PR on feat/windows-support (renamed branch, full WindowsPlatform + packaging in one PR).

@loss-and-quick
loss-and-quick deleted the feat/windows-proc-identity branch June 20, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant