diff options
author | Konstantin Belousov <kib@FreeBSD.org> | 2022-05-26 19:18:57 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2022-06-13 19:30:02 +0000 |
commit | 02a2aacbe2c81be455811fa9d4200101f70a86d2 (patch) | |
tree | 7ed38e05c399e71af7427caaab234a5fc4779da5 | |
parent | d3000939c7b94fc887f23dd8946861cf0fa1b73b (diff) | |
download | src-02a2aacbe2c81be455811fa9d4200101f70a86d2.tar.gz src-02a2aacbe2c81be455811fa9d4200101f70a86d2.zip |
issignal(): ignore signals when process is single-threading for exit
Places that will wait for curproc->p_singlethr to become zero (in the
next commit, the counter of number of external single-threading is
to be introduced), must wait for it interruptible, otherwise we
deadlock. On the other hand, a signal delivered during this window,
if directed to the waiting thread, would cause the wait loop to become
a busy loop.
Since we are exiting, it is safe to ignore the signals.
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D35310
-rw-r--r-- | sys/kern/kern_sig.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index afb2fd78c231..e3bbbd23ae6c 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2928,7 +2928,7 @@ sigprocess(struct thread *td, int sig) /* * We should allow pending but ignored signals below - * only if there is sigwait() active, or P_TRACED was + * if there is sigwait() active, or P_TRACED was * on when they were posted. */ if (SIGISMEMBER(ps->ps_sigignore, sig) && @@ -2937,6 +2937,16 @@ sigprocess(struct thread *td, int sig) return (SIGSTATUS_IGNORE); } + /* + * If the process is going to single-thread mode to prepare + * for exit, there is no sense in delivering any signal + * to usermode. Another important consequence is that + * msleep(..., PCATCH, ...) now is only interruptible by a + * suspend request. + */ + if ((p->p_flag2 & P2_WEXIT) != 0) + return (SIGSTATUS_IGNORE); + if ((p->p_flag & (P_TRACED | P_PPTRACE)) == P_TRACED) { /* * If traced, always stop. |