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

Use procfs to detect nr of open fd's if rlimit is too high (bsc#1191324) #349

Merged
merged 1 commit into from
Oct 12, 2021

Conversation

bzeller
Copy link
Contributor

@bzeller bzeller commented Oct 7, 2021

Especially in a VM iterating over all possible fd's to close open ones
right before a exec() slows down zypper unnecessarily. This patch uses
/proc/self/fd to iterate over open fd's in case rlimit is above 1024.

Especially in a VM iterating over all possible fd's to close open ones
right before a exec() slows down zypper unnecessarily. This patch uses
/proc/self/fd to iterate over open fd's in case rlimit is above 1024.
@mlandres mlandres merged commit 9200880 into openSUSE:master Oct 12, 2021
@bzeller bzeller deleted the fix-bsc-1191324 branch October 20, 2021 05:19
@crrodriguez
Copy link
Contributor

huh...no.. if you want close all open fds you have to use the close_range() system call and only do this /proc/self/fd iteration if invoking syscall return negative value..

@mlandres
Copy link
Member

mlandres commented Dec 6, 2021

Yes, we could check whether close_range is available. AFAICS not up to 15.3. Don't know if it's in 15.4, but TW seems to have it.

@crrodriguez
Copy link
Contributor

crrodriguez commented Dec 20, 2021

Yes, we could check whether close_range is available. AFAICS not up to 15.3. Don't know if it's in 15.4, but TW seems to have it.

even better, it should just use posix_spawn to execute things if the file action to close file descriptors on exec is available in the C library.. if posix_spawn_file_actions_addclosefrom_np is defined..
It is not that flexible but it is the cheapest/fastest way to run commands . Internally the C library uses it for pretty much all command execution functions (system, popen, wordexp..etc)

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

Successfully merging this pull request may close these issues.

None yet

3 participants