pub fn setrlimit(
    resource: Resource,
    soft_limit: u64,
    hard_limit: u64
) -> Result<(), Errno>
Expand description

Set the current processes resource limits

Parameters

  • resource: The Resource that we want to set the limits of.
  • soft_limit: The value that the kernel enforces for the corresponding resource.
  • hard_limit: The ceiling for the soft limit. Must be lower or equal to the current hard limit for non-root users.

The special value RLIM_INFINITY indicates that no limit will be enforced.

Examples


let soft_limit = 512;
let hard_limit = 1024;
setrlimit(Resource::RLIMIT_NOFILE, soft_limit, hard_limit).unwrap();

References

setrlimit(2)

Note: setrlimit provides a safe wrapper to libc’s setrlimit.