fix(subprocess): order runner stdio shutdown

This commit is contained in:
pku-xht committed 2026-08-21 07:49:15 +08:00
1 parent 975afc9e47
commit 889cbd45f1
1 file changed
+6 -6
@@ -102,6 +102,12 @@ function releaseRunnerStdio(): void {
const stdin = process.stdin
const stdout = process.stdout
const stderr = process.stderr
// A loader may already have materialized Node's libuv stdio wrappers. Their
// shutdown must be requested before the CRT descriptors close; the target
// keeps the handles CreateProcessW inherited and remains the only pipe writer.
stdin.destroy()
stdout.end()
stderr.end()
for (const fd of [0, 1, 2]) {
try {
closeSync(fd)
@@ -109,12 +115,6 @@ function releaseRunnerStdio(): void {
if ((error as NodeJS.ErrnoException).code !== 'EBADF') throw error
}
}
// A loader may already have materialized Node's libuv stdio wrappers. Settle
// those runner-owned references after closing the CRT descriptors; the target
// keeps the handles CreateProcessW inherited and remains the only pipe writer.
stdin.destroy()
stdout.end()
stderr.end()
}
async function runWin32(request: RunnerRequest, eventsPath: string): Promise<void> {