summaryrefslogtreecommitdiff
path: root/src/sys/ptrace.rs
diff options
context:
space:
mode:
authorxd009642 <danielmckenna93@gmail.com>2017-08-28 10:37:42 +0100
committerxd009642 <danielmckenna93@gmail.com>2017-08-28 10:37:42 +0100
commit178451910ee67ae226b8bdc5c01bf43ea8e5a9f8 (patch)
tree8b7dd0bd36e226d1fd3c9ff29e8ca8b3dfc7d6b7 /src/sys/ptrace.rs
parent33249db1c0f20491947c92e092961171a7bd4f68 (diff)
downloadnix-178451910ee67ae226b8bdc5c01bf43ea8e5a9f8.zip
Added detach function
Diffstat (limited to 'src/sys/ptrace.rs')
-rw-r--r--src/sys/ptrace.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs
index c5b88038..64b523c3 100644
--- a/src/sys/ptrace.rs
+++ b/src/sys/ptrace.rs
@@ -247,6 +247,20 @@ pub fn attach(pid: Pid) -> Result<()> {
}
}
+/// Detaches the current running process, as with `ptrace(PTRACE_DETACH, ...)`
+///
+/// Detaches from the process specified in pid allowing it to run freely
+pub fn detach(pid: Pid) -> Result<()> {
+ unsafe {
+ ptrace_other(
+ Request::PTRACE_DETACH,
+ pid,
+ ptr::null_mut(),
+ ptr::null_mut()
+ ).map(|_| ())
+ }
+}
+
/// Restart the stopped tracee process, as with `ptrace(PTRACE_CONT, ...)`
///
/// Continues the execution of the process with PID `pid`, optionally