Skip to content

Commit 1784519

Browse files
committed
Added detach function
1 parent 33249db commit 1784519

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2222
([#739](https://github.com/nix-rust/nix/pull/739))
2323
- Expose `signalfd` module on Android as well.
2424
([#739](https://github.com/nix-rust/nix/pull/739))
25+
- Added nix::sys::ptrace::detach.
26+
([#749](https://github.com/nix-rust/nix/pull/749))
2527

2628
### Changed
2729
- Renamed existing `ptrace` wrappers to encourage namespacing ([#692](https://github.com/nix-rust/nix/pull/692))

src/sys/ptrace.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ pub fn attach(pid: Pid) -> Result<()> {
247247
}
248248
}
249249

250+
/// Detaches the current running process, as with `ptrace(PTRACE_DETACH, ...)`
251+
///
252+
/// Detaches from the process specified in pid allowing it to run freely
253+
pub fn detach(pid: Pid) -> Result<()> {
254+
unsafe {
255+
ptrace_other(
256+
Request::PTRACE_DETACH,
257+
pid,
258+
ptr::null_mut(),
259+
ptr::null_mut()
260+
).map(|_| ())
261+
}
262+
}
263+
250264
/// Restart the stopped tracee process, as with `ptrace(PTRACE_CONT, ...)`
251265
///
252266
/// Continues the execution of the process with PID `pid`, optionally

0 commit comments

Comments
 (0)