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

fd: mark fds with CLOEXEC instead of closing them #84

Merged
merged 1 commit into from
Oct 27, 2023
Merged

Conversation

Snaipe
Copy link
Member

@Snaipe Snaipe commented Sep 19, 2023

--close-fd would fail to work on some systems when entering spacetimes where /proc would not be mounted, because it would attempt to iterate over all file descriptors as listed in /proc/self/fd right before execve, and of course this cannot work when /proc isn't there.

This fixes the problem by doing the operation earlier, after the setup script has ran, but before pivoting roots; of course, we can't close the range outright, since we're likely to use some of these file descriptors, but we can instead set the CLOEXEC bit on them.

--close-fd would fail to work on some systems when entering spacetimes
where /proc would not be mounted, because it would attempt to iterate
over all file descriptors as listed in /proc/self/fd right before
execve, and of course this cannot work when /proc isn't there.

This fixes the problem by doing the operation earlier, after the setup
script has ran, but before pivoting roots; of course, we can't close the
range outright, since we're likely to use some of these file
descriptors, but we can instead set the CLOEXEC bit on them.
@Snaipe Snaipe merged commit b65ff75 into main Oct 27, 2023
6 checks passed
@Snaipe Snaipe deleted the fix/close-fd branch October 27, 2023 15:11
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