Skip to content

fix: close inherited file descriptors in child process on Linux - #867

Merged
Daniel Imms (Tyriar) merged 5 commits into
mainfrom
tyriar/657
Jan 13, 2026
Merged

Daniel Imms (Tyriar) merged 5 commits into
mainfrom
tyriar/657

Conversation

@Tyriar

Copy link
Copy Markdown
Contributor

Prevents leaking file descriptors (pty master FDs, sockets, etc.) to child processes spawned via forkpty(). Uses close_range() syscall on Linux 5.9+, falling back to /proc/self/fd iteration, then brute force.

macOS already handles this via POSIX_SPAWN_CLOEXEC_DEFAULT flag.

Fixes #657
Part of microsoft/vscode#58814

Prevents leaking file descriptors (pty master FDs, sockets, etc.) to
child processes spawned via forkpty(). Uses close_range() syscall on
Linux 5.9+, falling back to /proc/self/fd iteration, then brute force.

macOS already handles this via POSIX_SPAWN_CLOEXEC_DEFAULT flag.

Fixes #657
Part of microsoft/vscode#58814
@Tyriar Daniel Imms (Tyriar) added this to the 1.2.0 milestone Jan 11, 2026
@Tyriar Daniel Imms (Tyriar) self-assigned this Jan 11, 2026
Comment thread src/unix/pty.cc Outdated
Comment thread src/unix/pty.cc Outdated
Daniel Imms (Tyriar) and others added 3 commits January 13, 2026 07:21
Co-authored-by: Robo <hop2deep@gmail.com>
Co-authored-by: Robo <hop2deep@gmail.com>
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.

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

2 participants