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