diff options
author | edef <edef@unfathomable.blue> | 2022-07-31 01:02:38 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-07-31 01:02:38 +0000 |
commit | f201365cc42088068044e5b5b7dea1a3d9320039 (patch) | |
tree | 857397c1fdedd4afe8b4f9c4c753a939546c0a1f | |
parent | c3b2795fbda4091ed7e2baa3f2fbd915e14cdc82 (diff) | |
download | unf-legacy-f201365cc42088068044e5b5b7dea1a3d9320039.tar.zst |
ripple/minitrace: terminate Process on drop
This ensures even outright panics in minitrace still cleanly terminate the process. Change-Id: I5debbae2e6e1bb38ef8782bbdf9f26661876fdbe
-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:?}"); } |