-/* $OpenBSD: kern_exec.c,v 1.219 2020/10/15 16:31:11 cheloha Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.220 2021/03/08 10:12:05 mpi Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
* we're committed: any further errors will kill the process, so
* kill the other threads now.
*/
- single_thread_set(p, SINGLE_EXIT, 0);
+ single_thread_set(p, SINGLE_EXIT, 1);
/*
* Prepare vmspace for remapping. Note that uvmspace_exec can replace
-/* $OpenBSD: kern_exit.c,v 1.196 2021/02/15 09:35:59 mpi Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.197 2021/03/08 10:12:05 mpi Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
} else {
/* nope, multi-threaded */
if (flags == EXIT_NORMAL)
- single_thread_set(p, SINGLE_EXIT, 0);
+ single_thread_set(p, SINGLE_EXIT, 1);
else if (flags == EXIT_THREAD)
single_thread_check(p, 0);
}
-/* $OpenBSD: kern_sig.c,v 1.274 2021/03/04 09:02:37 mpi Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.275 2021/03/08 10:12:05 mpi Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
/* if there are other threads, pause them */
if (P_HASSIBLING(p))
- single_thread_set(p, SINGLE_SUSPEND, 0);
+ single_thread_set(p, SINGLE_SUSPEND, 1);
if (coredump(p) == 0)
signum |= WCOREFLAG;
* where the other threads should stop:
* - SINGLE_SUSPEND: stop wherever they are, will later either be told to exit
* (by setting to SINGLE_EXIT) or be released (via single_thread_clear())
- * - SINGLE_PTRACE: stop wherever they are, will wait for them to stop
- * later (via single_thread_wait()) and released as with SINGLE_SUSPEND
* - SINGLE_UNWIND: just unwind to kernel boundary, will be told to exit
* or released as with SINGLE_SUSPEND
* - SINGLE_EXIT: unwind to kernel boundary and exit
*/
int
-single_thread_set(struct proc *p, enum single_thread_mode mode, int deep)
+single_thread_set(struct proc *p, enum single_thread_mode mode, int wait)
{
struct process *pr = p->p_p;
struct proc *q;
KASSERT(curproc == p);
SCHED_LOCK(s);
- error = single_thread_check_locked(p, deep, s);
+ error = single_thread_check_locked(p, (mode == SINGLE_UNWIND), s);
if (error) {
SCHED_UNLOCK(s);
return error;
switch (mode) {
case SINGLE_SUSPEND:
- case SINGLE_PTRACE:
break;
case SINGLE_UNWIND:
atomic_setbits_int(&pr->ps_flags, PS_SINGLEUNWIND);
/* if it's not interruptible, then just have to wait */
if (q->p_flag & P_SINTR) {
/* merely need to suspend? just stop it */
- if (mode == SINGLE_SUSPEND ||
- mode == SINGLE_PTRACE) {
+ if (mode == SINGLE_SUSPEND) {
q->p_stat = SSTOP;
break;
}
}
SCHED_UNLOCK(s);
- if (mode != SINGLE_PTRACE)
+ if (wait)
single_thread_wait(pr, 1);
return 0;