/rust/registry/src/index.crates.io-6f17d22bba15001f/rustix-1.0.8/src/process/rlimit.rs
Line | Count | Source (jump to first uncovered line) |
1 | | #[cfg(linux_kernel)] |
2 | | use crate::process::Pid; |
3 | | use crate::{backend, io}; |
4 | | |
5 | | pub use backend::process::types::Resource; |
6 | | |
7 | | /// `struct rlimit`—Current and maximum values used in [`getrlimit`], |
8 | | /// [`setrlimit`], and [`prlimit`]. |
9 | | #[derive(Debug, Clone, Copy, PartialEq, Eq)] |
10 | | pub struct Rlimit { |
11 | | /// Current effective, “soft”, limit. |
12 | | pub current: Option<u64>, |
13 | | /// Maximum, “hard”, value that `current` may be dynamically increased to. |
14 | | pub maximum: Option<u64>, |
15 | | } |
16 | | |
17 | | /// `getrlimit(resource)`—Get a process resource limit value. |
18 | | /// |
19 | | /// # References |
20 | | /// - [POSIX] |
21 | | /// - [Linux] |
22 | | /// |
23 | | /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/getrlimit.html |
24 | | /// [Linux]: https://man7.org/linux/man-pages/man2/getrlimit.2.html |
25 | | #[inline] |
26 | 0 | pub fn getrlimit(resource: Resource) -> Rlimit { |
27 | 0 | backend::process::syscalls::getrlimit(resource) |
28 | 0 | } |
29 | | |
30 | | /// `setrlimit(resource, new)`—Set a process resource limit value. |
31 | | /// |
32 | | /// # References |
33 | | /// - [POSIX] |
34 | | /// - [Linux] |
35 | | /// |
36 | | /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/setrlimit.html |
37 | | /// [Linux]: https://man7.org/linux/man-pages/man2/setrlimit.2.html |
38 | | #[inline] |
39 | 0 | pub fn setrlimit(resource: Resource, new: Rlimit) -> io::Result<()> { |
40 | 0 | backend::process::syscalls::setrlimit(resource, new) |
41 | 0 | } |
42 | | |
43 | | /// `prlimit(pid, resource, new)`—Get and set a process resource limit value. |
44 | | /// |
45 | | /// # References |
46 | | /// - [Linux] |
47 | | /// |
48 | | /// [Linux]: https://man7.org/linux/man-pages/man2/prlimit.2.html |
49 | | #[cfg(linux_kernel)] |
50 | | #[inline] |
51 | 0 | pub fn prlimit(pid: Option<Pid>, resource: Resource, new: Rlimit) -> io::Result<Rlimit> { |
52 | 0 | backend::process::syscalls::prlimit(pid, resource, new) |
53 | 0 | } |