1 use crate::process::Pid;
2 use crate::{backend, io};
3
4 pub use backend::process::types::Signal;
5
6 /// `kill(pid, sig)`—Sends a signal to a process.
7 ///
8 /// # References
9 /// - [POSIX]
10 /// - [Linux]
11 ///
12 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html
13 /// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
14 #[inline]
15 #[doc(alias = "kill")]
kill_process(pid: Pid, sig: Signal) -> io::Result<()>16 pub fn kill_process(pid: Pid, sig: Signal) -> io::Result<()> {
17 backend::process::syscalls::kill_process(pid, sig)
18 }
19
20 /// `kill(-pid, sig)`—Sends a signal to all processes in a process group.
21 ///
22 /// If `pid` is 1, this sends a signal to all processes the current process
23 /// has permission to send signals to, except process `1`, possibly other
24 /// system-specific processes, and on some systems, the current process.
25 ///
26 /// # References
27 /// - [POSIX]
28 /// - [Linux]
29 ///
30 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html
31 /// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
32 #[inline]
33 #[doc(alias = "kill")]
kill_process_group(pid: Pid, sig: Signal) -> io::Result<()>34 pub fn kill_process_group(pid: Pid, sig: Signal) -> io::Result<()> {
35 backend::process::syscalls::kill_process_group(pid, sig)
36 }
37
38 /// `kill(0, sig)`—Sends a signal to all processes in the current process
39 /// group.
40 ///
41 /// # References
42 /// - [POSIX]
43 /// - [Linux]
44 ///
45 /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html
46 /// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
47 #[inline]
48 #[doc(alias = "kill")]
kill_current_process_group(sig: Signal) -> io::Result<()>49 pub fn kill_current_process_group(sig: Signal) -> io::Result<()> {
50 backend::process::syscalls::kill_current_process_group(sig)
51 }
52