Function nix::sys::resource::setrlimit
pub fn setrlimit(resource: Resource, soft_limit: Option<rlim_t>, hard_limit: Option<rlim_t>) -> Result<()>Documentation
Set the current processes resource limits
Parameters
resource: TheResourcethat we want to set the limits of.soft_limit: The value that the kernel enforces for the corresponding resource. Note:Noneinput will be replaced by constantRLIM_INFINITY.hard_limit: The ceiling for the soft limit. Must be lower or equal to the current hard limit for non-root users. Note:Noneinput will be replaced by constantRLIM_INFINITY.
Note: for some os (linux_gnu), setting hard_limit to
RLIM_INFINITYcan resultsEPERMError. So you will need to set the number explicitly.
Examples
let soft_limit = Some(512);
let hard_limit = Some(1024);
setrlimit(Resource::RLIMIT_NOFILE, soft_limit, hard_limit).unwrap();References
Note: setrlimit provides a safe wrapper to libc’s setrlimit.