Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.1.2 Set the PTY fd to be non-blocking #36

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Conversation

lhchavez
Copy link
Contributor

We have gone back and forth a couple of times, but we do need to set this FD to be non-blocking. Otherwise node will fully consume one I/O thread for each PTY, and node only has four of those.

This change makes the controller fd (the one the parent process reads from / writes to) as non-blocking for node.

@lhchavez lhchavez force-pushed the lh-pty-nonblocking branch 2 times, most recently from 73b4b04 to e82d267 Compare July 15, 2024 17:01
Copy link
Member

@jackyzha0 jackyzha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodejs/node#42826 seems to imply that setting O_NONBLOCK on controller side fd is ok, our original issue of fcntl F_DUPFD_CLOEXEC failed: bad file descriptor (os error 9) is probably due to how we set autoClose before

Copy link
Member

@jackyzha0 jackyzha0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, seems like you still need to remove .only on the test

wrapper.ts Outdated Show resolved Hide resolved
@lhchavez lhchavez force-pushed the lh-pty-nonblocking branch 5 times, most recently from 9388cc4 to 6427a23 Compare July 15, 2024 22:35
We have gone back and forth a couple of times, but we _do_ need to set
this FD to be non-blocking. Otherwise node will fully consume one I/O
thread for each PTY, and node only has four of those.

This change makes the controller fd (the one the parent process reads
from / writes to) as non-blocking for node. Also, now that the
controller fd is non-blocking, we need to pass it through Node's TTY
machinery so that it is properly handled. Because of that, Rust is no
longer on the hook for closing the FD, since ownership is fully
transferred to Node.
@lhchavez lhchavez force-pushed the lh-pty-nonblocking branch from 6427a23 to 62807b2 Compare July 15, 2024 22:45
src/lib.rs Show resolved Hide resolved
tests/index.test.ts Show resolved Hide resolved
@lhchavez lhchavez merged commit f77eab0 into main Jul 15, 2024
4 checks passed
@lhchavez lhchavez deleted the lh-pty-nonblocking branch July 15, 2024 22:54
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