summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcin Mielniczuk <marmistrz.dev@zoho.eu>2017-07-31 10:50:45 +0200
committerMarcin Mielniczuk <marmistrz.dev@zoho.eu>2017-07-31 10:50:45 +0200
commit0fbac87ba58eb57b5c7aa360a274a16daa8de3fc (patch)
treea629a26a573c5044aeab41396c1cada9590d57f9 /src
parent843eeb008c3ba0476aa12f84ff4c01379a4d150c (diff)
downloadnix-0fbac87ba58eb57b5c7aa360a274a16daa8de3fc.zip
support delivering a signal with ptrace::cont
Diffstat (limited to 'src')
-rw-r--r--src/sys/ptrace.rs19
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
}
}
+