Skip to content

Conversation

@seangoedecke
Copy link

After the socket is created, this PR now triggers an empty read to make sure we catch stdio events like closing the stdin file descriptor. Otherwise those events will go undetected until the next stream write.

Fixes: #25131

After the socket is created, we trigger an empty read to make sure we
catch stdio events like closing the stdin file descriptor. Otherwise
those events will go undetected until the next stream write.

Fixes: nodejs#25131
@github-actions github-actions bot added child_process Issues and PRs related to the child_process subsystem. needs-ci PRs that need a full CI run. labels May 18, 2021
@aduh95
Copy link
Contributor

aduh95 commented Sep 20, 2023

Hey @seangoedecke, sorry your PR was not reviewed for so long! Any chance you would be able to rebase on top of main to get it back to a state where it can land? Or let me know if you prefer I do it for you.

stream.handle : null, i > 0);

// Trigger an empty read to check for a closed pipe
// or the close event will go undetected until next write
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// or the close event will go undetected until next write
// or the close event will go undetected until next write.

const fs = require('fs');

if (process.argv[2] === 'child') {
fs.closeSync(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use closeSync(0) rather than process.stdin.end()? If so, can you add a comment?

Copy link

Choose a reason for hiding this comment

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

as far as I understand the closeSync(0) is used because it needs to immediately close the standard input stream synchronously, however it's really good question why we cannot asynchronous handling of the end of the input stream?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

regression: child_process stdin pipe close event not emitted

3 participants