diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2019-11-17 19:04:28 -0800 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy@goop.org> | 2019-11-17 22:50:03 -0800 |
commit | a58d4eb57386803ac45d39aa48da5534a40a087e (patch) | |
tree | 4e0db947fef888405baf15826e2753610ae714d3 /src/sys/ptrace | |
parent | 5cb526d55df223735602d2f50cae4c9b43120d9c (diff) | |
download | nix-a58d4eb57386803ac45d39aa48da5534a40a087e.zip |
ptrace: add ptrace::seize for Linux
Diffstat (limited to 'src/sys/ptrace')
-rw-r--r-- | src/sys/ptrace/linux.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/sys/ptrace/linux.rs b/src/sys/ptrace/linux.rs index b2b984c3..ffe23d71 100644 --- a/src/sys/ptrace/linux.rs +++ b/src/sys/ptrace/linux.rs @@ -315,6 +315,21 @@ 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"))))] +pub fn seize(pid: Pid, options: Options) -> Result<()> { + unsafe { + ptrace_other( + Request::PTRACE_SEIZE, + pid, + ptr::null_mut(), + options.bits() as *mut c_void, + ).map(drop) // ignore the useless return value + } +} + /// Detaches the current running process, as with `ptrace(PTRACE_DETACH, ...)` /// /// Detaches from the process specified in pid allowing it to run freely |