Skip to content

feat(process): let the host choose how the supervisor stops - #219

Merged
4o3F merged 3 commits into
mainfrom
fix/process-stop-strategy
Nov 1, 2026
Merged

4o3F merged 3 commits into
mainfrom
fix/process-stop-strategy

Conversation

@4o3F

@4o3F 4o3F commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Implements the stop strategy from the review on #218 (which is closed in favor of this narrower change).

  • #[atomic_enum] StopStrategy { Graceful, Kill } and SupervisorBuilder::stop_strategy(Arc<AtomicStopStrategy>).
  • Supervisor::stop and the cascading cancellation branch both load(Acquire) the strategy at stop time and pass it to stop_process; Kill calls kill() directly, so no Ctrl+C shutdown helper is launched.
  • The host stores Kill (Release) before cancelling; without a strategy the behavior is unchanged.
  • No changes to Command, the engine, or backoff.

Tests (tests/process_supervisor.rs): Kill through stop() and through parent-token cancellation reaps the child and grandchild and observes a strategy stored after build; on Windows a marked helper is asserted not launched for Kill and launched for Graceful; default and explicit Graceful keep the graceful path.

Verified on Linux: fmt, clippy -D warnings, cargo test --all-features, docs, and cargo +nightly check --target x86_64-pc-windows-gnu --all-features --tests. Not yet run on Windows: process_supervisor / process_kill / process_helper_smoke for the Kill path still need a Windows run.

Refs libnyanpasu/clash-nyanpasu#6054

A session-end stop on Windows must not launch the Ctrl+C shutdown helper,
because new processes fail to initialize while the session is torn down.
Hosts inject an Arc<AtomicStopStrategy> at build time and store Kill before
cancelling; both Supervisor::stop and cascading cancellation read it when
they stop. Without a strategy the behavior is unchanged.

Refs libnyanpasu/clash-nyanpasu#6054
@semanticdiff-com

semanticdiff-com Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  src/process/mod.rs  47% smaller
  src/process/supervisor.rs  30% smaller
  tests/process_supervisor.rs  1% smaller
  Cargo.lock Unsupported file format
  Cargo.toml Unsupported file format
  tests/helpers/test_child.rs  0% smaller

@4o3F
4o3F merged commit 6d3574e into main Nov 1, 2026
4 checks passed
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