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