Function raise_nofile
pub fn raise_nofile(target: u64) -> Result<(), Error>Expand description
Raise the process soft file descriptor limit (RLIMIT_NOFILE) up to target.
Many network heavy applications such as HTTP proxies, gateways, and high concurrency servers can hit the per process open file descriptor limit and fail with errors like “Too many open files” (EMFILE). Sockets, accepted connections, pipes, and various runtime resources all consume file descriptors.
This utility reads the current RLIMIT_NOFILE limits and tries to increase the soft limit
(rlim_cur) to target, but never above the hard limit (rlim_max). If the current soft
limit is already greater than or equal to the computed new soft limit, this function does
nothing.
Notes
- This function does not attempt to raise the hard limit. Raising the hard limit typically requires elevated privileges or system configuration.
- In container or service environments, the effective hard limit may be constrained by the supervisor. For example systemd, launchd, Docker, Kubernetes.