gh-106140: Reorder some more fields to facilitate out-of-process inspection#106148
Conversation
|
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Sorry, @pablogsal, I could not cleanly backport this to |
|
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Sorry @pablogsal, I had trouble checking out the |
|
Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Sorry @pablogsal, I had trouble checking out the |
|
GH-106155 is a backport of this pull request to the 3.12 branch. |
…-process inspection (pythonGH-106148) (cherry picked from commit 9126a6a) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
…-process inspection (pythonGH-106148) (cherry picked from commit 9126a6a) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
``machina stop`` crashed on Windows whenever a configured port had an actual listener:: OSError: [WinError 87] The parameter is incorrect The above exception was the direct cause of the following exception: ... SystemError: <built-in function kill> returned a result with an exception set CPython issue python/cpython#106148: on Windows, ``os.kill(pid, signal.CTRL_BREAK_EVENT)`` calls ``GenerateConsoleCtrlEvent`` under the hood. When that fails with ``ERROR_INVALID_PARAMETER`` (e.g. target isn't in the caller's console group -- every port-bound service that wasn't spawned by our supervisor), CPython sets an ``OSError`` AND returns success. The interpreter detects the inconsistency and raises ``SystemError`` instead of propagating the underlying ``OSError``. ``cli/ports.py``'s ``kill_pid`` already had a fallback to ``proc.terminate()`` for the ``OSError`` case, but the ``except (OSError, ProcessLookupError)`` clause never caught ``SystemError`` -- so the bug propagated, typer printed a traceback, the process exited non-zero, and PowerShell (with its PS 7.4+ default ``$PSNativeCommandUseErrorActionPreference=$true`` plus a ``$ErrorActionPreference='Break'`` or ``Set-PSDebug`` in the user's profile) dropped into the debugger at the npm shim's ``$ret=$LASTEXITCODE`` line. Fix: add ``SystemError`` to the except tuple. The existing fallback to ``TerminateProcess`` (via ``psutil.terminate``) now runs as designed. End-to-end verified against the packed npm tarball: ``machina stop`` invoked from an installed bin shim kills a real process on port 3010 and exits 0 cleanly, no traceback. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.