diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c --- a/sys/kern/kern_thread.c +++ b/sys/kern/kern_thread.c @@ -1446,6 +1446,14 @@ return (TD_SBDRY_INTR(td) ? TD_SBDRY_ERRNO(td) : 0); } + /* + * We might get here with return_instead == 1 if + * other checks missed it. Then we must not suspend + * regardless of P_SHOULDSTOP() or debugger request. + */ + if (return_instead) + return (EINTR); + /* * If the process is waiting for us to exit, * this thread should just suicide. @@ -1481,10 +1489,9 @@ * gets taken off all queues. */ thread_suspend_one(td); - if (return_instead == 0) { - p->p_boundary_count++; - td->td_flags |= TDF_BOUNDARY; - } + MPASS(!return_instead); + p->p_boundary_count++; + td->td_flags |= TDF_BOUNDARY; PROC_SUNLOCK(p); mi_switch(SW_INVOL | SWT_SUSPEND); PROC_LOCK(p);