Skip to content

Commit 2583564

Browse files
committed
fix: better detaching process on a debugger drop
1 parent bb549f7 commit 2583564

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/debugger/mod.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -964,15 +964,17 @@ impl Drop for Debugger {
964964

965965
// todo currently ok only if all threads in group stop
966966
// continue all threads with SIGSTOP
967-
current_tids.iter().for_each(|tid| {
968-
sys::ptrace::cont(*tid, Signal::SIGSTOP).expect("cont debugee");
969-
});
970-
current_tids.iter().for_each(|tid| {
971-
waitpid(*tid, None).expect("waiting debugee");
972-
});
967+
let prepare_stopped: Vec<_> = current_tids
968+
.into_iter()
969+
.filter(|&tid| sys::ptrace::cont(tid, Signal::SIGSTOP).is_ok())
970+
.collect();
971+
let stopped: Vec<_> = prepare_stopped
972+
.into_iter()
973+
.filter(|&tid| waitpid(tid, None).is_ok())
974+
.collect();
973975
// detach ptrace
974-
current_tids.iter().for_each(|tid| {
975-
sys::ptrace::detach(*tid, None).expect("detach debugee");
976+
stopped.into_iter().for_each(|tid| {
977+
sys::ptrace::detach(tid, None).expect("detach tracee");
976978
});
977979
// kill debugee process
978980
signal::kill(self.debugee.tracee_ctl().proc_pid(), Signal::SIGKILL)

0 commit comments

Comments
 (0)