[−][src]Crate rlimit
rlimit - A simple wrapper for getrlimit
and setrlimit
.
Examples
Set resource limit
use rlimit::{setrlimit, Resource, Rlim}; const DEFAULT_SOFT_LIMIT: Rlim = Rlim::from_raw(4 * 1024 * 1024); const DEFAULT_HARD_LIMIT: Rlim = Rlim::from_raw(8 * 1024 * 1024); assert!(Resource::FSIZE.set(DEFAULT_SOFT_LIMIT, DEFAULT_HARD_LIMIT).is_ok()); let soft = Rlim::from_usize(16384); let hard = soft * 2; assert!(setrlimit(Resource::NOFILE, soft, hard).is_ok());
Get resource limit
use rlimit::{getrlimit, Resource, Rlim}; assert!(Resource::NOFILE.get().is_ok()); assert_eq!(getrlimit(Resource::CPU).unwrap(), (Rlim::INFINITY, Rlim::INFINITY));
Increase NOFILE limit
See the example nofile.
Structs
ProcLimit | [Linux] A process's resource limit field. |
ProcLimits | [Linux] A process's resource limits. It is parsed from the proc filesystem. |
Resource | A kind of resource. |
Rlim | Unsigned integer type used for limit values. |
Functions
getrlimit | Get resource limits. |
prlimit | [Linux] Set and get the resource limits of an arbitrary process. |
setrlimit | Set resource limits. |
Type Definitions
RawResource | Integer type used for resource values. |
RawRlim | Unsigned integer type used for limit values. |