ci: Improve daemonisation by closing only open FDs#309
Open
aarontomlin wants to merge 1 commit intoXilinx-CNS:masterfrom
Open
ci: Improve daemonisation by closing only open FDs#309aarontomlin wants to merge 1 commit intoXilinx-CNS:masterfrom
aarontomlin wants to merge 1 commit intoXilinx-CNS:masterfrom
Conversation
The ci_server_daemonise() function previously closed file descriptors by iterating from STDERR_FILENO + 1 up to the process's maximum limit (i.e., RLIMIT_NOFILE). This method is very inefficient when the file descriptor limit is very high; calling the close() system call a number of times for non-existent descriptors. This patch replaces the loop with a call to close_extra_fds(). This new function reads /proc/self/fd to identify and close only the applicable file descriptors currently open in the process. This provides a significant performance gain during daemonisation, especially on systems configured with large default file descriptor limits. If /proc is not available then revert back to the previously implementation i.e., iterating from file descriptors 3 to the value returned by getrlimit() for RLIMIT_NOFILE. Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
73dc236 to
aa2c592
Compare
Author
|
@ol-alexandra see the latest changes. |
ol-alexandra
approved these changes
Nov 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ci_server_daemonise() function previously closed file descriptors by iterating from STDERR_FILENO + 1 up to the process's maximum limit (i.e., RLIMIT_NOFILE). This method is very inefficient when the file descriptor limit is very high; calling the close() system call a number of times for non-existent descriptors.
This patch replaces the loop with a call to close_extra_fds(). This new function reads /proc/self/fd to identify and close only the applicable file descriptors currently open in the process.
This provides a significant performance gain during daemonisation, especially on systems configured with large default file descriptor limits. If /proc is not available then revert back to the previously implementation i.e., iterating from file descriptors 3 to the value returned by getrlimit() for RLIMIT_NOFILE.