PT_ATTACH: do not interrupt interruptible sleeps

Handle the first SIGSTOP from the PT_ATTACH specially: instead of waking
up some thread in the target process, execute sig_suspend_threads() in
the debugger. This is equivalent to the action of the xthread, except
that all threads are suspended without interruption.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D49678
This commit is contained in:
Konstantin Belousov 2025-04-16 03:09:44 +03:00
parent 4048ccc6ae
commit ecc662c749

View file

@ -2365,6 +2365,15 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi)
if (prop & SIGPROP_CONT)
sigqueue_delete_stopmask_proc(p);
else if (prop & SIGPROP_STOP) {
if ((p->p_flag & P_TRACED) != 0 &&
(p->p_flag2 & P2_PTRACE_FSTP) != 0) {
td->td_dbgflags |= TDB_FSTP;
PROC_SLOCK(p);
sig_handle_first_stop(td, p, sig, true);
PROC_SUNLOCK(p);
return (0);
}
/*
* If sending a tty stop signal to a member of an orphaned
* process group, discard the signal here if the action
@ -3345,7 +3354,8 @@ issignal(struct thread *td)
}
}
if ((p->p_flag & (P_TRACED | P_PPTRACE)) == P_TRACED &&
if (false &&
(p->p_flag & (P_TRACED | P_PPTRACE)) == P_TRACED &&
(p->p_flag2 & P2_PTRACE_FSTP) != 0 &&
SIGISMEMBER(sigpending, SIGSTOP)) {
/*