From 0fbac87ba58eb57b5c7aa360a274a16daa8de3fc Mon Sep 17 00:00:00 2001 From: Marcin Mielniczuk Date: Mon, 31 Jul 2017 10:50:45 +0200 Subject: support delivering a signal with ptrace::cont --- src/sys/ptrace.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src') 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>>(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 } } + -- cgit v1.2.3