summaryrefslogtreecommitdiff
path: root/src/sys/ptrace/bsd.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/ptrace/bsd.rs')
-rw-r--r--src/sys/ptrace/bsd.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/sys/ptrace/bsd.rs b/src/sys/ptrace/bsd.rs
index 7797d106..18265d31 100644
--- a/src/sys/ptrace/bsd.rs
+++ b/src/sys/ptrace/bsd.rs
@@ -77,16 +77,23 @@ pub fn traceme() -> Result<()> {
/// Attach to a running process, as with `ptrace(PT_ATTACH, ...)`
///
-/// Attaches to the process specified in pid, making it a tracee of the calling process.
+/// Attaches to the process specified by `pid`, making it a tracee of the calling process.
pub fn attach(pid: Pid) -> Result<()> {
unsafe { ptrace_other(Request::PT_ATTACH, pid, ptr::null_mut(), 0).map(drop) }
}
/// Detaches the current running process, as with `ptrace(PT_DETACH, ...)`
///
-/// Detaches from the process specified in pid allowing it to run freely
-pub fn detach(pid: Pid) -> Result<()> {
- unsafe { ptrace_other(Request::PT_DETACH, pid, ptr::null_mut(), 0).map(drop) }
+/// Detaches from the process specified by `pid` allowing it to run freely, optionally delivering a
+/// signal specified by `sig`.
+pub fn detach<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> {
+ let data = match sig.into() {
+ Some(s) => s as c_int,
+ None => 0,
+ };
+ unsafe {
+ ptrace_other(Request::PT_DETACH, pid, ptr::null_mut(), data).map(drop)
+ }
}
/// Restart the stopped tracee process, as with `ptrace(PTRACE_CONT, ...)`