diff options
Diffstat (limited to 'ripple/minitrace')
-rw-r--r-- | ripple/minitrace/src/main.rs | 13 |
1 files changed, 10 insertions, 3 deletions
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<CString> { 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:?}"); } |