Coverage Report

Created: 2025-11-09 06:46

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/rustix-1.1.2/src/process/kill.rs
Line
Count
Source
1
use crate::process::Pid;
2
use crate::{backend, io};
3
4
pub use crate::signal::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/9799919799/functions/kill.html
13
/// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
14
#[inline]
15
#[doc(alias = "kill")]
16
0
pub fn kill_process(pid: Pid, sig: Signal) -> io::Result<()> {
17
0
    backend::process::syscalls::kill_process(pid, sig)
18
0
}
19
20
/// `kill(-pid, sig)`—Sends a signal to all processes in a process group.
21
///
22
/// If `pid` is [`Pid::INIT`], this sends a signal to all processes the current
23
/// process has permission to send signals to, except process `Pid::INIT`,
24
/// possibly other system-specific processes, and on some systems, the current
25
/// process.
26
///
27
/// # References
28
///  - [POSIX]
29
///  - [Linux]
30
///
31
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/kill.html
32
/// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
33
#[inline]
34
#[doc(alias = "kill")]
35
0
pub fn kill_process_group(pid: Pid, sig: Signal) -> io::Result<()> {
36
0
    backend::process::syscalls::kill_process_group(pid, sig)
37
0
}
38
39
/// `kill(0, sig)`—Sends a signal to all processes in the current process
40
/// group.
41
///
42
/// # References
43
///  - [POSIX]
44
///  - [Linux]
45
///
46
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/kill.html
47
/// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
48
#[inline]
49
#[doc(alias = "kill")]
50
0
pub fn kill_current_process_group(sig: Signal) -> io::Result<()> {
51
0
    backend::process::syscalls::kill_current_process_group(sig)
52
0
}
53
54
/// `kill(pid, 0)`—Check validity of pid and permissions to send signals to
55
/// the process, without actually sending any signals.
56
///
57
/// # References
58
///  - [POSIX]
59
///  - [Linux]
60
///
61
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/kill.html
62
/// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
63
#[inline]
64
#[doc(alias = "kill")]
65
0
pub fn test_kill_process(pid: Pid) -> io::Result<()> {
66
0
    backend::process::syscalls::test_kill_process(pid)
67
0
}
68
69
/// `kill(-pid, 0)`—Check validity of pid and permissions to send signals to
70
/// all processes in the process group, without actually sending any signals.
71
///
72
/// # References
73
///  - [POSIX]
74
///  - [Linux]
75
///
76
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/kill.html
77
/// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
78
#[inline]
79
#[doc(alias = "kill")]
80
0
pub fn test_kill_process_group(pid: Pid) -> io::Result<()> {
81
0
    backend::process::syscalls::test_kill_process_group(pid)
82
0
}
83
84
/// `kill(0, 0)`—Check validity of pid and permissions to send signals to the
85
/// all processes in the current process group, without actually sending any
86
/// signals.
87
///
88
/// # References
89
///  - [POSIX]
90
///  - [Linux]
91
///
92
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/kill.html
93
/// [Linux]: https://man7.org/linux/man-pages/man2/kill.2.html
94
#[inline]
95
#[doc(alias = "kill")]
96
0
pub fn test_kill_current_process_group() -> io::Result<()> {
97
0
    backend::process::syscalls::test_kill_current_process_group()
98
0
}