Skip to main content

max_open_files

Function max_open_files 

Source
pub fn max_open_files(limits: &str) -> Option<(Option<u64>, Option<u64>)>
Expand description

The Max open files row of a /proc/<pid>/limits file, soft limit first.

None in either position is the file’s literal unlimited, the same thing fd_limits reports as None for RLIM_INFINITY. None for the pair means the text carries no Max open files row, or carries one that does not have two readable value columns. Those two are not told apart, because the caller has the same thing to say about either: there is no number to print.

This takes the file’s text rather than a pid, which is what makes it testable on the macOS development host where no such file exists. Reading the file, and finding the pid to read it for, belong to the one caller: volto --diagnostics, whose [file descriptors] section prints the running service’s limits beside the ones getrlimit reports for itself. The two differ whenever the command is typed into an SSH shell, because the service runs under the unit’s LimitNOFILE and the shell does not.

The kernel writes the row in fixed-width columns, and each value column is either a decimal number or the word unlimited:

Limit                     Soft Limit           Hard Limit           Units
Max open files            131072               131072               files