From 178451910ee67ae226b8bdc5c01bf43ea8e5a9f8 Mon Sep 17 00:00:00 2001 From: xd009642 Date: Mon, 28 Aug 2017 10:37:42 +0100 Subject: [PATCH] Added detach function --- CHANGELOG.md | 2 ++ src/sys/ptrace.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0aa4220bc..952bec13ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#739](https://github.com/nix-rust/nix/pull/739)) - Expose `signalfd` module on Android as well. ([#739](https://github.com/nix-rust/nix/pull/739)) +- Added nix::sys::ptrace::detach. + ([#749](https://github.com/nix-rust/nix/pull/749)) ### Changed - Renamed existing `ptrace` wrappers to encourage namespacing ([#692](https://github.com/nix-rust/nix/pull/692)) diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs index c5b880388e..64b523c3f5 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