git: f17eb93d5540 - main - When sending ignored signal, arrange for zero return code from sleep
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 06 Oct 2021 14:05:33 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f17eb93d5540ec2bf422d96195820bba5021fa9c commit f17eb93d5540ec2bf422d96195820bba5021fa9c Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2021-10-01 06:59:02 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2021-10-06 14:05:22 +0000 When sending ignored signal, arrange for zero return code from sleep Otherwise consumers get unexpected EINTR errors without seeing a properly discarded signal. Reported and tested by: trasz Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32252 --- sys/kern/kern_sig.c | 23 +++++++++++++---------- sys/kern/subr_sleepqueue.c | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index b20aea21333e..59e16ca8e6c8 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2214,17 +2214,20 @@ tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi) return (ret); } else { action = SIG_CATCH; + intrval = 0; } - } else if (SIGISMEMBER(td->td_sigmask, sig)) - action = SIG_HOLD; - else if (SIGISMEMBER(ps->ps_sigcatch, sig)) - action = SIG_CATCH; - else - action = SIG_DFL; - if (SIGISMEMBER(ps->ps_sigintr, sig)) - intrval = EINTR; - else - intrval = ERESTART; + } else { + if (SIGISMEMBER(td->td_sigmask, sig)) + action = SIG_HOLD; + else if (SIGISMEMBER(ps->ps_sigcatch, sig)) + action = SIG_CATCH; + else + action = SIG_DFL; + if (SIGISMEMBER(ps->ps_sigintr, sig)) + intrval = EINTR; + else + intrval = ERESTART; + } mtx_unlock(&ps->ps_mtx); if (prop & SIGPROP_CONT) diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c index 61efb1b9f377..8d61383f9737 100644 --- a/sys/kern/subr_sleepqueue.c +++ b/sys/kern/subr_sleepqueue.c @@ -1126,7 +1126,7 @@ sleepq_abort(struct thread *td, int intrval) THREAD_LOCK_ASSERT(td, MA_OWNED); MPASS(TD_ON_SLEEPQ(td)); MPASS(td->td_flags & TDF_SINTR); - MPASS(intrval == EINTR || intrval == ERESTART); + MPASS(intrval == 0 || intrval == EINTR || intrval == ERESTART); /* * If the TDF_TIMEOUT flag is set, just leave. A