Page MenuHomeFreeBSD

D32252.id96337.diff
No OneTemporary

D32252.id96337.diff

diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1278,8 +1278,11 @@
saved_mask = td->td_sigmask;
SIGSETNAND(td->td_sigmask, waitset);
if ((p->p_sysent->sv_flags & SV_SIG_DISCIGN) != 0 ||
- !kern_sig_discard_ign)
- td->td_pflags2 |= TDP2_SIGWAIT;
+ !kern_sig_discard_ign) {
+ thread_lock(td);
+ td->td_flags |= TDF_SIGWAIT;
+ thread_unlock(td);
+ }
for (;;) {
mtx_lock(&ps->ps_mtx);
sig = cursig(td);
@@ -1343,7 +1346,9 @@
if (error == 0 && (p->p_ptevents & PTRACE_SYSCALL) != 0)
traced = true;
}
- td->td_pflags2 &= ~TDP2_SIGWAIT;
+ thread_lock(td);
+ td->td_flags &= ~TDF_SIGWAIT;
+ thread_unlock(td);
new_block = saved_mask;
SIGSETNAND(new_block, td->td_sigmask);
@@ -2151,6 +2156,18 @@
(void) tdsendsignal(td->td_proc, td, sig, ksi);
}
+static int
+sig_sleepq_abort(struct thread *td, int intrval)
+{
+ THREAD_LOCK_ASSERT(td, MA_OWNED);
+
+ if (intrval == 0 && (td->td_flags & TDF_SIGWAIT) == 0) {
+ thread_unlock(td);
+ return (0);
+ }
+ return (sleepq_abort(td, intrval));
+}
+
int
tdsendsignal(struct proc *p, struct thread *td, int sig, ksiginfo_t *ksi)
{
@@ -2209,17 +2226,20 @@
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)
@@ -2366,7 +2386,7 @@
PROC_SLOCK(p);
thread_lock(td);
if (TD_CAN_ABORT(td))
- wakeup_swapper = sleepq_abort(td, intrval);
+ wakeup_swapper = sig_sleepq_abort(td, intrval);
else
thread_unlock(td);
PROC_SUNLOCK(p);
@@ -2497,7 +2517,7 @@
if (td->td_priority > PUSER && !TD_IS_IDLETHREAD(td))
sched_prio(td, PUSER);
- wakeup_swapper = sleepq_abort(td, intrval);
+ wakeup_swapper = sig_sleepq_abort(td, intrval);
PROC_SUNLOCK(p);
if (wakeup_swapper)
kick_proc0();
@@ -2951,7 +2971,7 @@
*/
if (SIGISMEMBER(ps->ps_sigignore, sig) &&
(p->p_flag & P_TRACED) == 0 &&
- (td->td_pflags2 & TDP2_SIGWAIT) == 0) {
+ (td->td_flags & TDF_SIGWAIT) == 0) {
sigqueue_delete(&td->td_sigqueue, sig);
sigqueue_delete(&p->p_sigqueue, sig);
continue;
@@ -3064,7 +3084,7 @@
mtx_lock(&ps->ps_mtx);
goto next;
} else if ((prop & SIGPROP_IGNORE) != 0 &&
- (td->td_pflags2 & TDP2_SIGWAIT) == 0) {
+ (td->td_flags & TDF_SIGWAIT) == 0) {
/*
* Default action is to ignore; drop it if
* not in kern_sigtimedwait().
@@ -3075,7 +3095,7 @@
/*NOTREACHED*/
case (intptr_t)SIG_IGN:
- if ((td->td_pflags2 & TDP2_SIGWAIT) == 0)
+ if ((td->td_flags & TDF_SIGWAIT) == 0)
break; /* == ignore */
else
return (sig);
diff --git a/sys/kern/subr_sleepqueue.c b/sys/kern/subr_sleepqueue.c
--- a/sys/kern/subr_sleepqueue.c
+++ b/sys/kern/subr_sleepqueue.c
@@ -1126,7 +1126,8 @@
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 && (td->td_flags & TDF_SIGWAIT) != 0) ||
+ intrval == EINTR || intrval == ERESTART);
/*
* If the TDF_TIMEOUT flag is set, just leave. A
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -446,7 +446,7 @@
#define TDF_TIMEOUT 0x00000010 /* Timing out during sleep. */
#define TDF_IDLETD 0x00000020 /* This is a per-CPU idle thread. */
#define TDF_CANSWAP 0x00000040 /* Thread can be swapped. */
-#define TDF_UNUSED80 0x00000080 /* unused. */
+#define TDF_SIGWAIT 0x00000080 /* Ignore ignored signals */
#define TDF_KTH_SUSP 0x00000100 /* kthread is suspended */
#define TDF_ALLPROCSUSP 0x00000200 /* suspended by SINGLE_ALLPROC */
#define TDF_BOUNDARY 0x00000400 /* Thread suspended at user boundary */
@@ -531,7 +531,6 @@
#define TDP2_SBPAGES 0x00000001 /* Owns sbusy on some pages */
#define TDP2_COMPAT32RB 0x00000002 /* compat32 ABI for robust lists */
#define TDP2_ACCT 0x00000004 /* Doing accounting */
-#define TDP2_SIGWAIT 0x00000008 /* Ignore ignored signals */
/*
* Reasons that the current thread can not be run yet.

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 16, 12:33 AM (19 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15423375
Default Alt Text
D32252.id96337.diff (4 KB)

Event Timeline