1 #[cfg(not(target_os = "espidf"))]
2 use crate::process::{Pid, Uid};
3 use crate::{backend, io};
4 
5 /// `nice(inc)`—Adjust the scheduling priority of the current process.
6 ///
7 /// # References
8 ///  - [POSIX]
9 ///  - [Linux]
10 ///
11 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/nice.html
12 /// [Linux]: https://man7.org/linux/man-pages/man2/nice.2.html
13 #[inline]
nice(inc: i32) -> io::Result<i32>14 pub fn nice(inc: i32) -> io::Result<i32> {
15     backend::process::syscalls::nice(inc)
16 }
17 
18 /// `getpriority(PRIO_USER, uid)`—Get the scheduling priority of the given
19 /// user.
20 ///
21 /// # References
22 ///  - [POSIX]
23 ///  - [Linux]
24 ///  - [Apple]
25 ///
26 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpriority.html
27 /// [Linux]: https://man7.org/linux/man-pages/man2/getpriority.2.html
28 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
29 #[cfg(not(target_os = "espidf"))]
30 #[inline]
31 #[doc(alias = "getpriority")]
getpriority_user(uid: Uid) -> io::Result<i32>32 pub fn getpriority_user(uid: Uid) -> io::Result<i32> {
33     backend::process::syscalls::getpriority_user(uid)
34 }
35 
36 /// `getpriority(PRIO_PGRP, gid)`—Get the scheduling priority of the given
37 /// process group.
38 ///
39 /// A `pgid` of `None` means the process group of the calling process.
40 ///
41 /// # References
42 ///  - [POSIX]
43 ///  - [Linux]
44 ///  - [Apple]
45 ///
46 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpriority.html
47 /// [Linux]: https://man7.org/linux/man-pages/man2/getpriority.2.html
48 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
49 #[cfg(not(target_os = "espidf"))]
50 #[inline]
51 #[doc(alias = "getpriority")]
getpriority_pgrp(pgid: Option<Pid>) -> io::Result<i32>52 pub fn getpriority_pgrp(pgid: Option<Pid>) -> io::Result<i32> {
53     backend::process::syscalls::getpriority_pgrp(pgid)
54 }
55 
56 /// `getpriority(PRIO_PROCESS, pid)`—Get the scheduling priority of the given
57 /// process.
58 ///
59 /// A `pid` of `None` means the calling process.
60 ///
61 /// # References
62 ///  - [POSIX]
63 ///  - [Linux]
64 ///  - [Apple]
65 ///
66 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpriority.html
67 /// [Linux]: https://man7.org/linux/man-pages/man2/getpriority.2.html
68 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
69 #[cfg(not(target_os = "espidf"))]
70 #[inline]
71 #[doc(alias = "getpriority")]
getpriority_process(pid: Option<Pid>) -> io::Result<i32>72 pub fn getpriority_process(pid: Option<Pid>) -> io::Result<i32> {
73     backend::process::syscalls::getpriority_process(pid)
74 }
75 
76 /// `setpriority(PRIO_USER, uid)`—Get the scheduling priority of the given
77 /// user.
78 ///
79 /// # References
80 ///  - [POSIX]
81 ///  - [Linux]
82 ///  - [Apple]
83 ///
84 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpriority.html
85 /// [Linux]: https://man7.org/linux/man-pages/man2/setpriority.2.html
86 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
87 #[cfg(not(target_os = "espidf"))]
88 #[inline]
89 #[doc(alias = "setpriority")]
setpriority_user(uid: Uid, priority: i32) -> io::Result<()>90 pub fn setpriority_user(uid: Uid, priority: i32) -> io::Result<()> {
91     backend::process::syscalls::setpriority_user(uid, priority)
92 }
93 
94 /// `setpriority(PRIO_PGRP, pgid)`—Get the scheduling priority of the given
95 /// process group.
96 ///
97 /// A `pgid` of `None` means the process group of the calling process.
98 ///
99 /// # References
100 ///  - [POSIX]
101 ///  - [Linux]
102 ///  - [Apple]
103 ///
104 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpriority.html
105 /// [Linux]: https://man7.org/linux/man-pages/man2/setpriority.2.html
106 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
107 #[cfg(not(target_os = "espidf"))]
108 #[inline]
109 #[doc(alias = "setpriority")]
setpriority_pgrp(pgid: Option<Pid>, priority: i32) -> io::Result<()>110 pub fn setpriority_pgrp(pgid: Option<Pid>, priority: i32) -> io::Result<()> {
111     backend::process::syscalls::setpriority_pgrp(pgid, priority)
112 }
113 
114 /// `setpriority(PRIO_PROCESS, pid)`—Get the scheduling priority of the given
115 /// process.
116 ///
117 /// A `pid` of `None` means the calling process.
118 ///
119 /// # References
120 ///  - [POSIX]
121 ///  - [Linux]
122 ///  - [Apple]
123 ///
124 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpriority.html
125 /// [Linux]: https://man7.org/linux/man-pages/man2/setpriority.2.html
126 /// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/setpriority.2.html
127 #[cfg(not(target_os = "espidf"))]
128 #[inline]
129 #[doc(alias = "setpriority")]
setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result<()>130 pub fn setpriority_process(pid: Option<Pid>, priority: i32) -> io::Result<()> {
131     backend::process::syscalls::setpriority_process(pid, priority)
132 }
133