diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-03-29 08:46:09 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-03-29 08:46:09 +0000 |
commit | 8968e89b3809cb0202d6fcc1e04edd34cd3f8bec (patch) | |
tree | 884fb1b15b074618c35763c1cd54485b13f30459 /sys | |
parent | 6f7da3aeb81f50768f177efae244fbc42f3669bc (diff) |
Use a macro to check if a thread has a sibling.
Note that without locking a thread cannot claim that it is part
of a multi-threaded process using this macro.
Suggested by miod@, ok guenther@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_exit.c | 5 | ||||
-rw-r--r-- | sys/kern/kern_sig.c | 5 | ||||
-rw-r--r-- | sys/sys/proc.h | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 5b36b203922..a66e6b36533 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.155 2016/03/06 05:20:26 guenther Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.156 2016/03/29 08:46:08 mpi Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -127,8 +127,7 @@ exit1(struct proc *p, int rv, int flags) pr = p->p_p; /* single-threaded? */ - if (TAILQ_FIRST(&pr->ps_threads) == p && - TAILQ_NEXT(p, p_thr_link) == NULL) { + if (!P_HASSIBLING(p)) { flags = EXIT_NORMAL; } else { /* nope, multi-threaded */ diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 611b1a4afde..23ead64a7e5 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.195 2016/03/26 21:38:54 beck Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.196 2016/03/29 08:46:08 mpi Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -1495,8 +1495,7 @@ sigexit(struct proc *p, int signum) p->p_sisig = signum; /* if there are other threads, pause them */ - if (TAILQ_FIRST(&p->p_p->ps_threads) != p || - TAILQ_NEXT(p, p_thr_link) != NULL) + if (P_HASSIBLING(p)) single_thread_set(p, SINGLE_SUSPEND, 0); if (coredump(p) == 0) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 2123e1a991e..d13ffac2ae6 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.217 2016/03/09 13:38:50 mpi Exp $ */ +/* $OpenBSD: proc.h,v 1.218 2016/03/29 08:46:08 mpi Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -364,6 +364,8 @@ struct proc { #define SONPROC 7 /* Thread is currently on a CPU. */ #define P_ZOMBIE(p) ((p)->p_stat == SDEAD) +#define P_HASSIBLING(p) (TAILQ_FIRST(&(p)->p_p->ps_threads) != (p) || \ + TAILQ_NEXT((p), p_thr_link) != NULL) /* * These flags are per-thread and kept in p_flag |