diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index e24be92726a..03697dc8a18 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2021,6 +2021,29 @@ tdsigwakeup(struct thread *td, int sig, sig_t action) #endif } +void +ptracestop(struct thread *td, int sig) +{ + struct proc *p = td->td_proc; + + WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, + &p->p_mtx.mtx_object, "Stopping for traced signal"); + + p->p_xstat = sig; + PROC_LOCK(p->p_pptr); + psignal(p->p_pptr, SIGCHLD); + PROC_UNLOCK(p->p_pptr); + mtx_lock_spin(&sched_lock); + stop(p); /* uses schedlock too eventually */ + thread_suspend_one(td); + PROC_UNLOCK(p); + DROP_GIANT(); + p->p_stats->p_ru.ru_nivcsw++; + mi_switch(); + mtx_unlock_spin(&sched_lock); + PICKUP_GIANT(); +} + /* * If the current process has received a signal (should be caught or cause * termination, should interrupt current syscall), return the signal number. @@ -2074,21 +2097,7 @@ issignal(td) * If traced, always stop. */ mtx_unlock(&ps->ps_mtx); - WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, - &p->p_mtx.mtx_object, "Stopping for traced signal"); - p->p_xstat = sig; - PROC_LOCK(p->p_pptr); - psignal(p->p_pptr, SIGCHLD); - PROC_UNLOCK(p->p_pptr); - mtx_lock_spin(&sched_lock); - stop(p); /* uses schedlock too eventually */ - thread_suspend_one(td); - PROC_UNLOCK(p); - DROP_GIANT(); - p->p_stats->p_ru.ru_nivcsw++; - mi_switch(); - mtx_unlock_spin(&sched_lock); - PICKUP_GIANT(); + ptracestop(td, sig); PROC_LOCK(p); mtx_lock(&ps->ps_mtx); diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 70b7904f2e0..a67c3ce7c03 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -276,6 +276,7 @@ void siginit(struct proc *p); void signotify(struct thread *td); void tdsignal(struct thread *td, int sig, sigtarget_t target); void trapsignal(struct thread *td, int sig, u_long code); +void ptracestop(struct thread *td, int sig); /* * Machine-dependent functions: