Skip to content

runtimetest: read RLIMIT_NOFILE from a child process - #822

Open
dangowrt wants to merge 1 commit into
opencontainers:masterfrom
dangowrt:rlimit-nofile-child
Open

dangowrt wants to merge 1 commit into
opencontainers:masterfrom
dangowrt:rlimit-nofile-child

Conversation

@dangowrt

Copy link
Copy Markdown
Contributor

Since Go 1.19 the runtime raises its own soft RLIMIT_NOFILE to one below the hard limit at start-up (syscall/rlimit.go), so runtimetest reads that raised value instead of the one the runtime configured, and the soft RLIMIT_NOFILE check fails against every runtime whenever the configured soft limit is lower than the hard one (e.g. expected: 3000, actual: 3999 with a hard limit of 4000).

Go restores the original limit in the processes it starts, so this reads RLIMIT_NOFILE from /proc/self/limits of a /bin/cat child; the other limits are untouched by Go and are still read directly. The parser has unit tests, and a test checks that a child's hard limit matches ours and its soft limit does not exceed ours.

Since Go 1.19 the runtime raises its own soft RLIMIT_NOFILE to one below
the hard limit at start-up, so runtimetest reads that raised value and
not the one the runtime configured: the soft RLIMIT_NOFILE check fails
against every runtime whenever the configured soft limit is lower. Go
restores the original limit in the processes it starts, so read the
limits of a child from its /proc/self/limits instead; the other limits
are left untouched by Go and are still read directly.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
@dangowrt
dangowrt marked this pull request as ready for review October 20, 2026 19:07
@dangowrt
dangowrt requested a review from a team as a code owner October 20, 2026 19:07
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.

1 participant