#unix #syscall #rlimit

rlimit

A simple wrapper for getrlimit and setrlimit

7 releases (4 breaking)

0.5.2 Oct 14, 2020
0.5.1 Oct 13, 2020
0.4.0 Aug 13, 2020
0.3.0 Jul 29, 2019
0.1.0 Apr 5, 2019

#17 in Unix APIs

Download history 554/week @ 2020-07-05 792/week @ 2020-07-12 1355/week @ 2020-07-19 1684/week @ 2020-07-26 3172/week @ 2020-08-02 1393/week @ 2020-08-09 1262/week @ 2020-08-16 2431/week @ 2020-08-23 1013/week @ 2020-08-30 1765/week @ 2020-09-06 1669/week @ 2020-09-13 1675/week @ 2020-09-20 1881/week @ 2020-09-27 1470/week @ 2020-10-04 1923/week @ 2020-10-11 1580/week @ 2020-10-18

7,267 downloads per month
Used in less than 7 crates

MIT license

37KB
770 lines

rlimit

Latest Version Documentation License

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.

Dependencies

~225KB