Skip to content

fix: clear FD_CLOEXEC on stdio fds in spawn_inherited#172

Merged
branchseer merged 2 commits intomainfrom
fix-stdout-missing
Feb 25, 2026
Merged

fix: clear FD_CLOEXEC on stdio fds in spawn_inherited#172
branchseer merged 2 commits intomainfrom
fix-stdout-missing

Conversation

@fengmk2
Copy link
Copy Markdown
Member

@fengmk2 fengmk2 commented Feb 25, 2026

libuv (used by Node.js) marks stdin/stdout/stderr as close-on-exec,
which causes them to be closed when the child process calls exec().
This resulted in the child's fds 0-2 being closed after exec, and
Node.js reopening them as /dev/null, silently discarding all output.

Add a pre_exec hook to spawn_inherited() that clears FD_CLOEXEC on
fds 0, 1, 2 before exec, matching the existing fix in vite-plus's
vite_command::fix_stdio_streams().

Ref: libuv/libuv#2062

libuv (used by Node.js) marks stdin/stdout/stderr as close-on-exec,
which causes them to be closed when the child process calls exec().
This resulted in the child's fds 0-2 being closed after exec, and
Node.js reopening them as /dev/null, silently discarding all output.

Add a pre_exec hook to spawn_inherited() that clears FD_CLOEXEC on
fds 0, 1, 2 before exec, matching the existing fix in vite-plus's
vite_command::fix_stdio_streams().

Ref: libuv/libuv#2062
@fengmk2 fengmk2 self-assigned this Feb 25, 2026
Copy link
Copy Markdown
Member Author

fengmk2 commented Feb 25, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Member Author

fengmk2 commented Feb 25, 2026

everything come back now voidzero-dev/vite-plus@127038a

@fengmk2 fengmk2 marked this pull request as ready for review February 25, 2026 09:04
@fengmk2 fengmk2 requested a review from branchseer February 25, 2026 09:04
@branchseer
Copy link
Copy Markdown
Member

@fengmk2 I removed the added test since it can't validate the fix without the node environment. Let's do the test in vite-plus.

@branchseer branchseer merged commit 97e7aac into main Feb 25, 2026
7 checks passed
@branchseer branchseer deleted the fix-stdout-missing branch February 25, 2026 09:43
fengmk2 added a commit to voidzero-dev/vite-plus that referenced this pull request Feb 25, 2026
fengmk2 added a commit to voidzero-dev/vite-plus that referenced this pull request Feb 25, 2026
fengmk2 added a commit to voidzero-dev/vite-plus that referenced this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants