diff options
author | Marcin Mielniczuk <marmistrz.dev@zoho.eu> | 2017-07-31 10:50:45 +0200 |
---|---|---|
committer | Marcin Mielniczuk <marmistrz.dev@zoho.eu> | 2017-07-31 10:50:45 +0200 |
commit | 0fbac87ba58eb57b5c7aa360a274a16daa8de3fc (patch) | |
tree | a629a26a573c5044aeab41396c1cada9590d57f9 /src | |
parent | 843eeb008c3ba0476aa12f84ff4c01379a4d150c (diff) | |
download | nix-0fbac87ba58eb57b5c7aa360a274a16daa8de3fc.zip |
support delivering a signal with ptrace::cont
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/ptrace.rs | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/sys/ptrace.rs b/src/sys/ptrace.rs index 4f2a27e5..b6c64362 100644 --- a/src/sys/ptrace.rs +++ b/src/sys/ptrace.rs @@ -4,6 +4,7 @@ use std::{mem, ptr}; use {Errno, Error, Result}; use libc::{c_void, c_long, siginfo_t}; use ::unistd::Pid; +use sys::signal::Signal; pub mod ptrace { use libc::c_int; @@ -188,15 +189,15 @@ pub fn attach(pid: Pid) -> Result<()> { /// Restart the stopped tracee process, as with `ptrace(PTRACE_CONT, ...)` /// -/// No stop request is done as a part of this call. -/// No signal is delivered to the process. -pub fn cont(pid: Pid) -> Result<()> { +/// Continues the execution of the process with PID `pid`, optionally +/// delivering a signal specified by `sig`. +pub fn cont<T: Into<Option<Signal>>>(pid: Pid, sig: T) -> Result<()> { + let data = match sig.into() { + Some(s) => s as i32 as *mut c_void, + None => ptr::null_mut(), + }; unsafe { - ptrace( - ptrace::PTRACE_CONT, - pid, - ptr::null_mut(), - ptr::null_mut(), - ).map(|_| ()) // ignore the useless return value + ptrace(ptrace::PTRACE_CONT, pid, ptr::null_mut(), data).map(|_| ()) // ignore the useless return value } } + |