diff options
Diffstat (limited to 'ripple/minitrace/src')
-rw-r--r-- | ripple/minitrace/src/main.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 2d21f8b..34c503c 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -62,6 +62,14 @@ struct Process { pidfd: PidFd, } +impl Drop for Process { + fn drop(&mut self) { + if let Err(err) = self.terminate() { + eprintln!("{err}"); + } + } +} + impl Process { fn spawn(cmd: &mut Command) -> Result<Process> { unsafe { @@ -248,14 +256,10 @@ fn main() -> Result<()> { let regs = ptrace::getregs(event_tid.as_pid())?; let entry = match SyscallEntry::from_regs(&process, regs) { Ok(entry) => entry, - Err(err) => { - process.terminate()?; - panic!("{err}"); - } + Err(err) => panic!("{err}"), }; if !check_syscall(&entry) { - process.terminate()?; panic!("invalid syscall {entry:?}"); } |