From 39945afb70eb59ef348c512e8d3447027d13929c Mon Sep 17 00:00:00 2001 From: edef Date: Sun, 31 Jul 2022 00:57:43 +0000 Subject: ripple/minitrace: use kill(2) over PTRACE_KILL PTRACE_KILL is deprecated, and the manpage recommends using kill(pid, SIGKILL) instead. Change-Id: I8eda5a7add224838c2b01ef8b6999560bae446eb --- ripple/minitrace/src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ripple/minitrace/src') diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 9d577de..5bc6e23 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -12,7 +12,7 @@ use { personality::{self, Persona}, ptrace, resource::{self, Resource as HostResource}, - signal::Signal as HostSignal, + signal::{kill, Signal as HostSignal}, wait::{waitpid, WaitPidFlag, WaitStatus}, }, unistd::Pid, @@ -103,6 +103,13 @@ impl Process { }) } + fn terminate(&self) -> Result<()> { + match kill(self.tgid.as_pid(), HostSignal::SIGKILL) { + Ok(()) | Err(nix::Error::ESRCH) => Ok(()), + Err(err) => Err(anyhow::Error::from(err).context("Couldn't terminate child")), + } + } + fn read_mem_cstr(&self, ptr: u64) -> Result { let mut mem = io::BufReader::new(&self.mem); mem.seek(SeekFrom::Start(ptr))?; @@ -234,13 +241,13 @@ fn main() -> Result<()> { let entry = match SyscallEntry::from_regs(&process, regs) { Ok(entry) => entry, Err(err) => { - ptrace::kill(event_tid.as_pid())?; + process.terminate()?; panic!("{err}"); } }; if !check_syscall(&entry) { - ptrace::kill(event_tid.as_pid())?; + process.terminate()?; panic!("invalid syscall {entry:?}"); } -- cgit 1.4.1