Skip to content

Port ndx's process stopping for parity - #59

Merged
kzu merged 3 commits into
mainfrom
feat/ndx-stop-parity
Nov 19, 2026
Merged

kzu merged 3 commits into
mainfrom
feat/ndx-stop-parity

Conversation

@kzu

@kzu kzu commented Nov 19, 2026

Copy link
Copy Markdown
Member

Ports the process stopping logic of ndx (ProcessStop/ChildProcess) for parity, adapted to stopping a process we did not start.

  • Process tree: the processes the target started are recorded before the signal and while waiting (they are reparented once it exits), then waited for within the same --timeout.
  • New -k|--kill: kills whatever is still running when the timeout expires, with its process tree. Opt-in: ndx always kills because it must restart the tool.
  • Windows: WM_CLOSE first, then Ctrl+C through stopr, as in ndx. This fixes GUI apps started from a shell: stopr attached to the shell's console and reported success, so the window never closed. Console windows (ConsoleWindowClass, PseudoConsoleWindow) are never sent WM_CLOSE, which would close the console instead of sending Ctrl+C.
  • NeoAstra apps: only unowned top-level NeoAstra.Window frames get WM_CLOSE.
  • Unix: SIGINT through libc kill(). procps-ng kill -INT -<pgid> exited 0 without signaling anything. Only the target is signaled when its process group is our own (e.g. app & dnx stop $! in a script).

Smoke-tested on Windows (console, hidden/visible console, GUI, NeoAstra layout, process tree, timeout, --kill, piped PIDs) and on Linux under WSL (SIGINT, process tree, timeout, --kill, same-group guard). Not tested on macOS or with a Native AOT Linux build.

🤖 Generated with Claude Code

This pull request was created by CodeAlta.

Follow ndx's ProcessStop/ChildProcess, adapted to stopping a process we did not start:

- Record the processes the target started before signaling it and while waiting, since they
  are reparented once it exits, and wait for them within the same timeout.
- Add -k|--kill to kill what is still running when the timeout expires, with its process tree.
- On Windows, send WM_CLOSE first and Ctrl+C through stopr second. A GUI app started from a
  shell has no console, and stopr attached to the shell's console instead and reported success.
  Console windows are never sent WM_CLOSE, which would close the console instead of Ctrl+C.
- Close NeoAstra apps through their unowned top-level NeoAstra.Window frames only.
- On Unix, send SIGINT with libc kill(): procps-ng kill took "-INT -<pgid>" without signaling
  and exited with 0. Signal only the target when its process group is our own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
@kzu kzu added the enhancement New feature or request label Nov 19, 2026
@kzu
kzu enabled auto-merge (rebase) November 19, 2026 03:37
kzu and others added 2 commits November 19, 2026 00:41
The /proc checks ended the wait at once on macOS, which has no /proc, so
stop returned while the target was still shutting down and --timeout and
--kill never applied. They now run on Linux only; macOS waits for
Process.HasExited. The process group comes from libc getpgid() on every
Unix, so macOS also sends SIGINT to the group.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
With RuntimeIdentifiers=any and PublishAot=true, the .NET 11 SDK drops 'any'
from the RID-specific tool packages (AOT packs only RIDs the host compiles
natively) and, with none left, re-packs the project with an empty
RuntimeIdentifier: MSB4006, circular dependency on
_CreateRIDSpecificToolPackages. Turn AOT off when building only for 'any',
and build -r any (after a restore) before the solution, since packing the
solution now packs stop.any from that build's output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: CodeAlta <noreply@codealta.io>
@kzu
kzu merged commit bd1990c into main Nov 19, 2026
4 checks passed
@kzu
kzu deleted the feat/ndx-stop-parity branch November 19, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant