summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2003-07-03 19:09:59 +0000
committermtm <mtm@FreeBSD.org>2003-07-03 19:09:59 +0000
commit6f4ee681fdadfbb7008a43761f43ef8fe7d4f5c1 (patch)
tree77ce7442dc945271c4d10bcf0fc6db6bf3b8de78 /sys/kern/kern_sig.c
parent87561c3aaf68e1a2b0f3365dbecea35358f05f52 (diff)
downloadFreeBSD-src-6f4ee681fdadfbb7008a43761f43ef8fe7d4f5c1.zip
FreeBSD-src-6f4ee681fdadfbb7008a43761f43ef8fe7d4f5c1.tar.gz
Signals sent specifically to a particular thread must
be delivered to that thread, regardless of whether it has it masked or not. Previously, if the targeted thread had the signal masked, it would be put on the processes' siglist. If another thread has the signal umasked or unmasks it before the target, then the thread it was intended for would never receive it. This patch attempts to solve the problem by requiring callers of tdsignal() to say whether the signal is for the thread or for the process. If it is for the process, then normal processing occurs and any thread that has it unmasked can receive it. But if it is destined for a specific thread, it is put on that thread's pending list regardless of whether it is currently masked or not. The new behaviour still needs more work, though. If the signal is reposted for some reason it is always posted back to the thread that handled it because the information regarding the target of the signal has been lost by then. Reviewed by: jdp, jeff, bde (style)
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 7f5ef68..8d22399 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -95,7 +95,7 @@ static int filt_signal(struct knote *kn, long hint);
static struct thread *sigtd(struct proc *p, int sig, int prop);
static int kern_sigtimedwait(struct thread *td, sigset_t set,
siginfo_t *info, struct timespec *timeout);
-static void do_tdsignal(struct thread *td, int sig);
+static void do_tdsignal(struct thread *td, int sig, sigtarget_t target);
struct filterops sig_filtops =
{ 0, filt_sigattach, filt_sigdetach, filt_signal };
@@ -761,7 +761,7 @@ sigwait(struct thread *td, struct sigwait_args *uap)
/* Repost if we got an error. */
if (error && info.si_signo) {
PROC_LOCK(td->td_proc);
- tdsignal(td, info.si_signo);
+ tdsignal(td, info.si_signo, SIGTARGET_TD);
PROC_UNLOCK(td->td_proc);
}
return (error);
@@ -800,7 +800,7 @@ sigtimedwait(struct thread *td, struct sigtimedwait_args *uap)
/* Repost if we got an error. */
if (error && info.si_signo) {
PROC_LOCK(td->td_proc);
- tdsignal(td, info.si_signo);
+ tdsignal(td, info.si_signo, SIGTARGET_TD);
PROC_UNLOCK(td->td_proc);
} else {
td->td_retval[0] = info.si_signo;
@@ -831,7 +831,7 @@ sigwaitinfo(struct thread *td, struct sigwaitinfo_args *uap)
/* Repost if we got an error. */
if (error && info.si_signo) {
PROC_LOCK(td->td_proc);
- tdsignal(td, info.si_signo);
+ tdsignal(td, info.si_signo, SIGTARGET_TD);
PROC_UNLOCK(td->td_proc);
} else {
td->td_retval[0] = info.si_signo;
@@ -1538,7 +1538,7 @@ trapsignal(struct thread *td, int sig, u_long code)
mtx_unlock(&ps->ps_mtx);
p->p_code = code; /* XXX for core dump/debugger */
p->p_sig = sig; /* XXX to verify code */
- tdsignal(td, sig);
+ tdsignal(td, sig, SIGTARGET_TD);
}
PROC_UNLOCK(p);
}
@@ -1607,21 +1607,21 @@ psignal(struct proc *p, int sig)
*/
td = sigtd(p, sig, prop);
- tdsignal(td, sig);
+ tdsignal(td, sig, SIGTARGET_P);
}
/*
* MPSAFE
*/
void
-tdsignal(struct thread *td, int sig)
+tdsignal(struct thread *td, int sig, sigtarget_t target)
{
sigset_t saved;
struct proc *p = td->td_proc;
if (p->p_flag & P_SA)
saved = p->p_siglist;
- do_tdsignal(td, sig);
+ do_tdsignal(td, sig, target);
if ((p->p_flag & P_SA) && !(p->p_flag & P_SIGEVENT)) {
if (SIGSETEQ(saved, p->p_siglist))
return;
@@ -1634,7 +1634,7 @@ tdsignal(struct thread *td, int sig)
}
static void
-do_tdsignal(struct thread *td, int sig)
+do_tdsignal(struct thread *td, int sig, sigtarget_t target)
{
struct proc *p;
register sig_t action;
@@ -1656,10 +1656,12 @@ do_tdsignal(struct thread *td, int sig)
/*
* If this thread is blocking this signal then we'll leave it in the
- * proc so that we can find it in the first thread that unblocks it.
+ * proc so that we can find it in the first thread that unblocks
+ * it-- unless the signal is meant for the thread and not the process.
*/
- if (SIGISMEMBER(td->td_sigmask, sig))
- siglist = &p->p_siglist;
+ if (target == SIGTARGET_P)
+ siglist = SIGISMEMBER(td->td_sigmask, sig) ?
+ &p->p_siglist : &td->td_siglist;
else
siglist = &td->td_siglist;
OpenPOWER on IntegriCloud