JPY_PARENT_PID is a PID, but ipykernel treats it as a HANDLE on Windows: parent-death kernel shutdown (#1559) is inactive on win32 #1691
Closed
chimin-roh
started this conversation in
Bug reports
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
v0.8.0 ships "Kernels exit when their owner dies" (#1559). On Windows the mechanism does not arm, so kernels can outlive their owner exactly as before.
packages/coding-agent/src/core/kernel/index.ts:745passes:On POSIX, ipykernel's
ParentPollerUnixtreats this as a PID and the chain works. On Windows,kernelapp.init_poller()selectsParentPollerWindows, which passes the value toWaitForMultipleObjectsas a process HANDLE, not a PID.jupyter_clientdoes this correctly: it creates an inheritable handle withDuplicateHandleand passes that handle value (jupyter_client/launcher.py).Evidence
WaitForSingleObjectwith a livenode.exePID returnsWAIT_FAILED(0xFFFFFFFF) withGetLastError = 6 (ERROR_INVALID_HANDLE).Parent poll failed. If the frontend dies, the kernel may be left running.and the poller thread exits, so no parent watch is active.test/kernel-parent-watchdog.test.ts:492), so CI does not cover this path.Impact
The remaining safety net is the supervisor orphan journal (
cli/owned-session-worker.ts:299-313), which only helps while the supervisor is alive. If the process tree is killed (for exampletaskkill /f /im node.exe, which Windows users do reach for), the kernel survives.Suggested fix
On win32, duplicate the current process handle as inheritable and pass the handle value instead of the PID, mirroring
jupyter_client.launcher. Keep the PID for POSIX.Happy to test a patch on Windows 11 (ACP 949) if that is useful.
All reactions