Skip to content

Leaking FDs: Close non-std FDs between pty_forkpty and pty_execvpe #657

Open
@htfy96

Description

@htfy96

Environment details

  • OS: Linux
  • OS version: Linux 6.7
  • node-pty version: The one bundled in VSCode, and I believe it still exists on master

Issue description

Related to microsoft/vscode#202558 .

Currently node-pty doesn't close unwanted fds before spawning the process in pty_execvpe. This caused the above issue where Node's open fd(s) accidentally leaks into the spawned process. Considering that very few spawned shell process are aware to the non-std fds, I doubt if this would ever be the desired behavior.

To reduce the amount of surprise, I hope it could do something like https://github.com/facebook/folly/blob/main/folly/Subprocess.cpp#L559 to close all unwanted fds before spawning the shell.


EDIT from @Tyriar:

Lots more information in #710

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bughelp wantedIssues identified as good community contribution opportunities

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions