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

Make the Pty constructor take an object #10

Merged
merged 3 commits into from
May 6, 2024
Merged

Conversation

lhchavez
Copy link
Contributor

@lhchavez lhchavez commented May 5, 2024

The Pty constructor is going to grow soon, so might as well make this refactor now.

This change makes some of the parameters to Pty optional for ergonomics.

lhchavez added 2 commits May 5, 2024 17:38
Previously we used to close the fd immediately after the process was
terminated. That made lifetimes simple to reason about, but we
accidentally introduced a very subtle bug: If bun hadn't read the
entirety of the stdout/stderr of the child process, since Rust would
close the file from under it, Bun would not be able to read the rest of
the output, truncating it!

This change now adds an explicit `close()` and `fd()` functions so that
the fd management becomes way more explicit than before. Tests were also
updated to ensure that there are no leaked FDs, since now we lost the
guarantee that everything was going to be cleaned up properly.
The Pty constructor is going to grow soon, so might as well make this
refactor now.

This change makes some of the parameters to Pty optional for ergonomics.
Base automatically changed from lh-fix-race-between-process-death-and-stdio-read to main May 6, 2024 08:27
@szymonkaliski szymonkaliski merged commit 443152a into main May 6, 2024
5 checks passed
@szymonkaliski szymonkaliski deleted the lh-pty-ctor-object branch May 6, 2024 08:36
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