Skip to content

Commit

Permalink
ptrace: add ptrace::seize for Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgf committed Nov 18, 2019
1 parent 5cb526d commit c527385
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/sys/ptrace/linux.rs
Expand Up @@ -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) -> Result<()> {
unsafe {
ptrace_other(
Request::PTRACE_SEIZE,
pid,
ptr::null_mut(),
ptr::null_mut(),
).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
Expand Down

0 comments on commit c527385

Please sign in to comment.