-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(windows spawn): use Job Object to manage subprocesses of subprocesses #11240
Conversation
❌ @paperdave, your commit has failing tests :( 💪 2 failing tests Darwin AARCH64
💻 4 failing tests Darwin x64
🐧💪 3 failing tests Linux AARCH64
🪟💻 8 failing tests Windows x64 baseline
🪟💻 9 failing tests Windows x64
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general, see my comment about the race condition
src/bun.js/api/bun/process.zig
Outdated
if (bun.windows.CreateJobObjectA(null, null)) |job| | ||
_ = bun.windows.AssignProcessToJobObject(job, process.poller.uv.process_handle); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the process has already spawned a child process and then exited by the time it's being assigned to the job object? See this blog for context. Not sure if this is an edge case we should care about, but might be relevant.
To do it the "right" way we might need to mess with libuv internals for process spawning, not sure if we want to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i moved this to just the code for --watch (libuv already does this and actually did it more correct than what i have here), and i followed the linked guide so that we spawn the process without this race. thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now 👍
Changes look good now, however there seems to be a test failure in |
I think the hot and watch tests need to pass before this PR can be merged |
What does this PR do?
See test case, note how --watch spawns two processes, but before, the
kill
in the outermost process would keep the innermost subprocess alive. Now, callingkill
in the outermost process kills the whole tree. This was an issue if the caller of this process tree depended on standard io, which would not be closed before. Now, since the processes are dead, the standard io is closed.