Skip to content

Suspend Windows processes until job objects are set up#15850

Merged
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/windows-process-suspend
May 30, 2025
Merged

Suspend Windows processes until job objects are set up#15850
straight-shoota merged 1 commit intocrystal-lang:masterfrom
HertzDevil:bug/windows-process-suspend

Conversation

@HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented May 28, 2025

Under rare conditions, a newly created Windows process might have terminated so fast that LibC.AssignProcessToJobObject fails with ERROR_ACCESS_DENIED, because it requires an alive process (e.g. https://github.com/crystal-lang/crystal/actions/runs/15293884475/job/43022118390). This PR prevents that by creating the process in a suspended state and resuming it after the LibC.AssignProcessToJobObject call.

In this case, LibC.GetExitCodeProcess inside #wait must return a valid exit code that isn't LibC::STILL_ACTIVE.

@HertzDevil HertzDevil added the kind:bug A bug in the code. Does not apply to documentation, specs, etc. label May 28, 2025
@HertzDevil HertzDevil added platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system labels May 28, 2025
@HertzDevil HertzDevil moved this to Review in Windows Support May 28, 2025
@straight-shoota straight-shoota added this to the 1.17.0 milestone May 28, 2025
@straight-shoota straight-shoota merged commit a45a78d into crystal-lang:master May 30, 2025
39 checks passed
@github-project-automation github-project-automation bot moved this from Review to Done in Windows Support May 30, 2025
@HertzDevil HertzDevil deleted the bug/windows-process-suspend branch May 30, 2025 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:windows Windows support based on the MSVC toolchain / Win32 API topic:stdlib:system

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants