Skip to content

spawn with CREATE_NO_WINDOW on Windows#66

Merged
jmcphers merged 3 commits into
mainfrom
bugfix/windows-spawn
Jun 9, 2026
Merged

spawn with CREATE_NO_WINDOW on Windows#66
jmcphers merged 3 commits into
mainfrom
bugfix/windows-spawn

Conversation

@jmcphers

@jmcphers jmcphers commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

On Windows, R sessions fail to start with exit code 0xC0000142 (STATUS_DLL_INIT_FAILED) after Positron is closed and reopened against an already-running supervisor.

The supervisor is normally launched inside a terminal whose pseudoconsole (conpty) is owned by Positron. When Positron exits, that pseudoconsole is destroyed. In setups where the supervisor outlives Positron (e.g. it gets orphaned instead of cleaned up, which we've seen on Windows Server / Remote Desktop installs), the supervisor is left holding a dead console handle. Kernels spawned afterwards inherited that dead console and died during process initialization, before producing any output, so the user just saw the session fail to start.

Change

On Windows, kernel processes are now spawned with the CREATE_NO_WINDOW flag, giving each kernel its own hidden console instead of inheriting the supervisor's. This isolates kernels from the supervisor's console lifetime, so they start cleanly even when the supervisor's original console is gone.

We also use a job object to replace the former implicit termination that happened when R/Python inherited the console of the supervisor.

Notes

This addresses the spawn-side failure. It does not change the separate question of why the supervisor is sometimes left running after Positron exits.

Discovered while investigating posit-dev/positron#13951, but doesn't necessarily close the issue.

@jmcphers jmcphers requested a review from samclark2015 June 5, 2026 23:48

@samclark2015 samclark2015 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this on my Windows VM. Did not encounter any issues, but notably was not able to test in the RDP setup described in the issue.

@jmcphers jmcphers merged commit a0127c7 into main Jun 9, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants