fix(subprocess): create control carriers for overlapped Windows I/O

This commit is contained in:
Tianyi Cui committed 2026-09-12 15:03:00 +08:00
1 parent 63d462f28b
commit 83a45679df
3 files changed
+6 -3

No files matched your search

@@ -129,7 +129,7 @@ export function runnerStdio(
if (!ipc) {
if (spec.stdio.control === 'pipe') {
while (targetStdio.length < SUBPROCESS_CONTROL_FD) targetStdio.push('ignore')
targetStdio.push('pipe')
targetStdio.push('overlapped')
}
return targetStdio
}
@@ -142,7 +142,7 @@ export function runnerStdio(
spec.stdio.stdout === 'inherit' ? 1 : 'pipe',
spec.stdio.stderr === 'inherit' ? 2 : 'pipe',
]
if (spec.stdio.control === 'pipe') runner.push('pipe')
if (spec.stdio.control === 'pipe') runner.push('overlapped')
return runner
}
@@ -657,7 +657,7 @@ export function spawnSubprocess(spec: SubprocessSpawnSpec, internals: SpawnInter
]
if (spec.stdio.control === 'pipe') {
while (stdio.length < SUBPROCESS_CONTROL_FD) stdio.push('ignore')
stdio.push('pipe')
stdio.push('overlapped')
}
const child = (internals.spawn ?? spawn)(program as string, args, {
cwd: spec.cwd,
@@ -274,6 +274,9 @@ describe('runner launch inputs', () => {
expect(parseRunnerTargetArgv(['--', 'node', 'a'])).toEqual(['node', 'a'])
expect(() => parseRunnerTargetArgv(['node'])).toThrow('private -- delimiter')
expect(runnerStdio(spec, false)).toEqual(['pipe', 'pipe', 'inherit'])
const withControl = { ...spec, stdio: { ...spec.stdio, control: 'pipe' as const } }
expect(runnerStdio(withControl, false)).toEqual(['pipe', 'pipe', 'inherit', 'ignore', 'ignore', 'ignore', 'ignore', 'overlapped'])
expect(runnerStdio(withControl, true)).toEqual(['ignore', 'ignore', 'ignore', 'ipc', 'pipe', 'pipe', 2, 'overlapped'])
expect(runnerStdio(spec, true)).toEqual([
'ignore', 'ignore', 'ignore', 'ipc', 'pipe', 'pipe', 2,
])