child_process: add PTY support for spawn and spawnSync#64501
Open
lygstate wants to merge 13 commits into
Open
Conversation
- Use the u.fd space conveniently added in UV_HANDLE_FIELDS.
- Do so by introducing a `uv_spawn2` and `uv_process_options2_t`.
- The TTY_NAME_MAX constant isn't available on MacOS. Use - `sysconf(_SC_TTY_NAME_MAX)` instead.
- Both GetProcAddress as well as LoadLibrary are fairly expensive. So cache - the result. This is racy, but it doesn't matter much, on a collision we'll - do a bit of throw away work, but the assignment of `pfnResize` is atomic. - So nothing bad will happen.
- Should be at least 128KiB according to lhecker++.
- kernel32.dll will always be loaded, so we can just retrieve its handle - instead of loading it.
- Let's just punt on the EOF vs EIO issue.
Collaborator
|
Review requested:
|
Contributor
|
Thanks for working on this, but maybe a better way to patch libuv deps is to commit these code to independent libuv repo? |
Contributor
|
Could you take some time to read doc/contributing/pull-requests |
Author
libuv/libuv#4802 its here |
Contributor
You should check this doc/contributing/maintaining/maintaining-dependencies |
Archkon
reviewed
Jul 14, 2026
| @@ -0,0 +1,72 @@ | |||
| # Plan: PTY support in `child_process` (custom fork) | |||
Contributor
There was a problem hiding this comment.
This document maybe not suitable for being placed in this direactory
mcollina
requested changes
Jul 14, 2026
mcollina
left a comment
Member
There was a problem hiding this comment.
There are many changes to libuv. Those should be sent to libuv.
- Expose options.pty and stdio 'pty' so children get a real TTY via libuv ConPTY/openpty, with combined stdout and null stderr. - Wire process_wrap and spawn_sync to uv_spawn2, pty cols/rows, and uv_pty_resize; skip early PTY stdin shutdown that ConPTY treats as CTRL_C. - Reject incompatible options (windowsHide; detached on Windows), replace TERM when pty.name is set, and throw from resize on invalid state. - Add docs, contributing plan, and parallel coverage for remap, TERM, shell, validation, and resize.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
options.pty/stdio: 'pty'tochild_process.spawn()andspawnSync()so children can run with a real TTY (libuv PTY / ConPTY), combined stdout, andstderr === null.uv_spawn2,UV_PROCESS_PTY,uv_pty_resize) and wire Node bindings, including ConPTY-safe stdin handling andsubprocess.resize().windowsHide, Windowsdetached, stdin cannot be'pty') and add parallel test coverage.Refs: #64019
The libuv deps MR is at
libuv/libuv#4802
Test plan
tools/test.py parallel/test-child-process-spawn-ptyspawn/spawnSyncwithpty: true,resize(), andinputwithout CTRL_CisTTYtrue for stdout/stderr under PTYwindowsHide+ptyand Windowsdetached+ptyreject withERR_INVALID_ARG_VALUE