summaryrefslogtreecommitdiff
path: root/src/sys/ptrace
diff options
context:
space:
mode:
authorMika Vatanen <blaind@blaind.net>2021-04-11 10:39:46 +0300
committerMika Vatanen <blaind@blaind.net>2021-08-09 20:29:44 +0300
commit1cbde2bb472507bdc6b84ec9ba6172dfcc2c01c5 (patch)
treeac2820918c5ff7b20f6d75d430cbefc21d9d5488 /src/sys/ptrace
parent4c4be116f6414dbc9258f67102ea4b525efc037f (diff)
downloadnix-1cbde2bb472507bdc6b84ec9ba6172dfcc2c01c5.zip
Add PTRACE_INTERRUPT
Diffstat (limited to 'src/sys/ptrace')
-rw-r--r--src/sys/ptrace/linux.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/sys/ptrace/linux.rs b/src/sys/ptrace/linux.rs
index 74a23e03..ef1dafbb 100644
--- a/src/sys/ptrace/linux.rs
+++ b/src/sys/ptrace/linux.rs
@@ -98,11 +98,9 @@ libc_enum!{
#[cfg(all(target_os = "linux", not(any(target_arch = "mips",
target_arch = "mips64"))))]
PTRACE_SETREGSET,
- #[cfg(all(target_os = "linux", not(any(target_arch = "mips",
- target_arch = "mips64"))))]
+ #[cfg(target_os = "linux")]
PTRACE_SEIZE,
- #[cfg(all(target_os = "linux", not(any(target_arch = "mips",
- target_arch = "mips64"))))]
+ #[cfg(target_os = "linux")]
PTRACE_INTERRUPT,
#[cfg(all(target_os = "linux", not(any(target_arch = "mips",
target_arch = "mips64"))))]
@@ -339,7 +337,7 @@ pub fn attach(pid: Pid) -> Result<()> {
/// Attach to a running process, as with `ptrace(PTRACE_SEIZE, ...)`
///
/// Attaches to the process specified in pid, making it a tracee of the calling process.
-#[cfg(all(target_os = "linux", not(any(target_arch = "mips", target_arch = "mips64"))))]
+#[cfg(target_os = "linux")]
pub fn seize(pid: Pid, options: Options) -> Result<()> {
unsafe {
ptrace_other(
@@ -384,6 +382,16 @@ pub fn cont<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> {
}
}
+/// Stop a tracee, as with `ptrace(PTRACE_INTERRUPT, ...)`
+///
+/// This request is equivalent to `ptrace(PTRACE_INTERRUPT, ...)`
+#[cfg(target_os = "linux")]
+pub fn interrupt(pid: Pid) -> Result<()> {
+ unsafe {
+ ptrace_other(Request::PTRACE_INTERRUPT, pid, ptr::null_mut(), ptr::null_mut()).map(drop)
+ }
+}
+
/// Issues a kill request as with `ptrace(PTRACE_KILL, ...)`
///
/// This request is equivalent to `ptrace(PTRACE_CONT, ..., SIGKILL);`