From d6add3a39a71081efe8b5b45ba2ed8a4f5075969 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Fri, 29 Sep 2023 21:45:07 -0400 Subject: Prevent lingering traps after detach There can sometimes be a pending SIGTRAP when we resume a thread. This is usually due to interrupting a hung single-step. If this trap is hit after the debugger leaves, the original process will crash. This is a quick workaround to attempt to consume such traps ourselves before detaching. Signed-off-by: Malfurious --- debugger.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/debugger.c b/debugger.c index 878ce21..46a6a15 100644 --- a/debugger.c +++ b/debugger.c @@ -288,6 +288,9 @@ struct process *dbg_attach(pid_t pid, int child) { } int dbg_detach(struct process *proc) { + interrupt_all_threads(proc); + dbg_realcont(proc->threads.head); + usleep(100000); interrupt_all_threads(proc); uninstall_breakpoints(proc->threads.head); free_breakpoints(proc); -- cgit v1.2.3