Skip to content

child_process: stdout support stream#62386

Draft
Tseian wants to merge 4 commits intonodejs:mainfrom
Tseian:fix/spawnsync-stdio-52776
Draft

child_process: stdout support stream#62386
Tseian wants to merge 4 commits intonodejs:mainfrom
Tseian:fix/spawnsync-stdio-52776

Conversation

@Tseian
Copy link
Contributor

@Tseian Tseian commented Mar 22, 2026

Issue

#52776

Description

Enable child_process.spawnSync() to accept wrapped libuv streams (stdio.wrap) as stdio targets (e.g. passing another child process’ stdin), so synchronous spawns can participate in stream wiring the same way spawn() does.

This makes it possible to forward a spawnSync() child’s output directly into an existing stream without creating intermediate pipes.

Before

Passing an existing stream as a spawnSync() stdio entry (the stdio.wrap path) would fail (e.g. rejected as invalid / not handled), preventing patterns like wiring spawnSync() output into another child process’ stdin.

After

spawnSync() supports stdio.wrap by inheriting the provided uv_stream_t for the requested fd, allowing spawnSync() output to be forwarded into an existing stream.

Changes

  • src/spawn_sync.cc
  • src/spawn_sync.h
  • test/parallel/test-child-process-spawnsync.js

Test

  • test/parallel/test-child-process-spawnsync.js
    • Adds coverage for using another child process stream as a spawnSync() stdio target and verifies data is forwarded correctly.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels Mar 22, 2026
@Tseian Tseian changed the title WIP Fixes: https://github.com/nodejs/node/issues/52776 child_process: stdin support stream Mar 23, 2026
Explicitly close the wrapped stream for childA to receive EOF.
@Tseian Tseian changed the title child_process: stdin support stream child_process: stdout support stream Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants