limits-rs

Build Status Crate Docs License

A Rust library for determining the limits that an operating system enforce on a given particular process.

Operating systems support

In its current implementation, this crate allows convenient read of the /proc/<pid>/limits file on GNU/Linux. On any other platform, the provided methods will return an error so that the user can decide what to do in the absence of information about limits.

Support for other operating systems and platforms may be added on demand. Feel free to file an issue or make a PR!

Examples

Checking the limits for a specific PID

```rust use limitsrs::getpid_limits;

// Let's check what the CPU time hard limit is for process 1. let limits = getpidlimits(1).unwrap(); let maxcputimehardlimit = limits.maxcputime.hard;

// This will print either: // - "Some(x)" if there is a limit, where x is the limit itself. // - "None" if it is "unlimited". println!("{}", maxcputimehardlimit); ```

Checking the limits for our own PID

```rust use limitsrs::getpid_limits;

// Let's check what the open files soft limit is for our own process. let limits = getownlimits().unwrap(); let maxopenfilessoftlimit = limits.maxopenfiles.soft;

// This will print either: // - "Some(x)" if there is a limit, where x is the limit itself. // - "None" if it is "unlimited". println!("{}", maxopenfilessoftlimit); ```

Supported "limitable" properties

GNU/Linux

The properties currently tracked by limits-rs::linux::Limits are:

Other operating systems

As said before, support for other operating systems and platforms may be added on demand. Feel free to file an issue or make a PR!

License

Scriptful is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See [LICENSE-APACHE] and [LICENSE-MIT], and [COPYRIGHT] for details.