Skip to content

fix: walk /proc/self/fd when close_range is not available - #1012

Open
Konstantin Adzer (AdzerKI) wants to merge 1 commit into
microsoft:mainfrom
AdzerKI:proc-fd-cloexec
Open

Konstantin Adzer (AdzerKI) wants to merge 1 commit into
microsoft:mainfrom
AdzerKI:proc-fd-cloexec

Conversation

@AdzerKI

Copy link
Copy Markdown

Fixes #1011

Without close_range, pty_close_inherited_fds() now sets FD_CLOEXEC on every fd listed in /proc/self/fd, read with getdents64 since readdir() may allocate in the forked child. The existing loop stays for when /proc is not available.

The leak test now opens and closes a block of fds before spawning the third pty, so the masters of the first two sit above a gap. Built against the glibc 2.28 sysroot as CI does, it fails without the change (3 ptmx fds in the shell) and passes with it; npm test and lint are green.

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.

Linux: fds above a gap in fd numbers leak into the spawned process when close_range isn't compiled in

1 participant