aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/kern_sig.c
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2002-10-01 17:15:53 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2002-10-01 17:15:53 +0000
commit1d9c56964d81bb47d6c0787d316f09984b064b5b (patch)
tree07d2fcfbfe85d84af8cf79f8fec57733afa19e18 /sys/kern/kern_sig.c
parent689cd8eeb891bcc4bf05d3fec0bdcbf28d236b45 (diff)
downloadsrc-1d9c56964d81bb47d6c0787d316f09984b064b5b.tar.gz
src-1d9c56964d81bb47d6c0787d316f09984b064b5b.zip
Back our kernel support for reliable signal queues.
Requested by: rwatson, phk, and many others
Notes
Notes: svn path=/head/; revision=104306
Diffstat (limited to 'sys/kern/kern_sig.c')
-rw-r--r--sys/kern/kern_sig.c64
1 files changed, 28 insertions, 36 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index ada2016af2ae..f6fa38b720c7 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,6 +1,4 @@
/*
- * Copyright (c) 2002 New Gold Technoloy. All rights reserved.
- * Copyright (c) 2002 Juli Mallett. All rights reserved.
* Copyright (c) 1982, 1986, 1989, 1991, 1993
* The Regents of the University of California. All rights reserved.
* (c) UNIX System Laboratories, Inc.
@@ -72,7 +70,6 @@
#include <sys/sysctl.h>
#include <sys/malloc.h>
#include <sys/unistd.h>
-#include <sys/ksiginfo.h>
#include <machine/cpu.h>
@@ -119,9 +116,6 @@ static int do_coredump = 1;
SYSCTL_INT(_kern, OID_AUTO, coredump, CTLFLAG_RW,
&do_coredump, 0, "Enable/Disable coredumps");
-static int stopmask =
- sigmask(SIGSTOP) | sigmask(SIGTSTP) | sigmask(SIGTTIN) | sigmask(SIGTTOU);
-
/*
* Signal properties and actions.
* The array below categorizes the signals and their default actions
@@ -184,12 +178,12 @@ cursig(struct thread *td)
PROC_LOCK_ASSERT(p, MA_OWNED);
mtx_assert(&sched_lock, MA_NOTOWNED);
- return (signal_pending(p) ? issignal(td) : 0);
+ return (SIGPENDING(p) ? issignal(td) : 0);
}
/*
* Arrange for ast() to handle unmasked pending signals on return to user
- * mode. This must be called whenever a signal is added to p_sigq or
+ * mode. This must be called whenever a signal is added to p_siglist or
* unmasked in p_sigmask.
*/
void
@@ -200,7 +194,7 @@ signotify(struct proc *p)
PROC_LOCK_ASSERT(p, MA_OWNED);
mtx_lock_spin(&sched_lock);
- if (signal_pending(p)) {
+ if (SIGPENDING(p)) {
p->p_sflag |= PS_NEEDSIGCHK;
/* XXXKSE for now punish all KSEs */
FOREACH_KSEGRP_IN_PROC(p, kg) {
@@ -347,7 +341,7 @@ kern_sigaction(td, sig, act, oact, old)
(sigprop(sig) & SA_IGNORE &&
ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL)) {
/* never to be seen again */
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
if (sig != SIGCONT)
/* easier in psignal */
SIGADDSET(p->p_sigignore, sig);
@@ -500,7 +494,7 @@ execsigs(p)
if (sigprop(sig) & SA_IGNORE) {
if (sig != SIGCONT)
SIGADDSET(p->p_sigignore, sig);
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
}
ps->ps_sigact[_SIG_IDX(sig)] = SIG_DFL;
}
@@ -647,7 +641,7 @@ sigpending(td, uap)
mtx_lock(&Giant);
PROC_LOCK(p);
- ksiginfo_to_sigset_t(p, &siglist);
+ siglist = p->p_siglist;
PROC_UNLOCK(p);
mtx_unlock(&Giant);
error = copyout(&siglist, uap->set, sizeof(sigset_t));
@@ -670,12 +664,10 @@ osigpending(td, uap)
struct osigpending_args *uap;
{
struct proc *p = td->td_proc;
- sigset_t siglist;
mtx_lock(&Giant);
PROC_LOCK(p);
- ksiginfo_to_sigset_t(p, &siglist);
- SIG2OSIG(siglist, td->td_retval[0]);
+ SIG2OSIG(p->p_siglist, td->td_retval[0]);
PROC_UNLOCK(p);
mtx_unlock(&Giant);
return (0);
@@ -1316,7 +1308,7 @@ psignal(p, sig)
}
if (prop & SA_CONT)
- signal_delete_mask(p, stopmask);
+ SIG_STOPSIGMASK(p->p_siglist);
if (prop & SA_STOP) {
/*
@@ -1329,10 +1321,10 @@ psignal(p, sig)
(p->p_pgrp->pg_jobc == 0) &&
(action == SIG_DFL))
return;
- signal_delete_mask(p, sigmask(SIGCONT));
+ SIG_CONTSIGMASK(p->p_siglist);
p->p_flag &= ~P_CONTINUED;
}
- signal_add(p, NULL, sig);
+ SIGADDSET(p->p_siglist, sig);
signotify(p); /* uses schedlock */
/*
@@ -1370,10 +1362,10 @@ psignal(p, sig)
if (prop & SA_CONT) {
/*
* If SIGCONT is default (or ignored), we continue the
- * process but don't leave the signal in p_sigq as it
- * has no further action. If SIGCONT is held, we
+ * process but don't leave the signal in p_siglist as
+ * it has no further action. If SIGCONT is held, we
* continue the process and leave the signal in
- * p_sigq. If the process catches SIGCONT, let it
+ * p_siglist. If the process catches SIGCONT, let it
* handle the signal itself. If it isn't waiting on
* an event, it goes back to run state.
* Otherwise, process goes back to sleep state.
@@ -1381,7 +1373,7 @@ psignal(p, sig)
p->p_flag &= ~P_STOPPED_SIG;
p->p_flag |= P_CONTINUED;
if (action == SIG_DFL) {
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
} else if (action == SIG_CATCH) {
/*
* The process wants to catch it so it needs
@@ -1411,7 +1403,7 @@ psignal(p, sig)
* Just make sure the signal STOP bit set.
*/
p->p_flag |= P_STOPPED_SIG;
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
goto out;
}
@@ -1445,7 +1437,7 @@ psignal(p, sig)
/*
* Already active, don't need to start again.
*/
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
goto out;
}
if ((p->p_flag & P_TRACED) || (action != SIG_DFL) ||
@@ -1469,7 +1461,7 @@ psignal(p, sig)
mtx_unlock_spin(&sched_lock);
stop(p);
p->p_xstat = sig;
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
PROC_LOCK(p->p_pptr);
if ((p->p_pptr->p_procsig->ps_flag &
PS_NOCLDSTOP) == 0) {
@@ -1486,7 +1478,7 @@ psignal(p, sig)
/* NOTREACHED */
} else {
/* Not in "NORMAL" state. discard the signal. */
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
goto out;
}
@@ -1561,7 +1553,7 @@ tdsignal(struct thread *td, int sig, sig_t action)
* be awakened.
*/
if ((prop & SA_CONT) && action == SIG_DFL) {
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
return;
}
@@ -1617,13 +1609,13 @@ issignal(td)
for (;;) {
int traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG);
- ksiginfo_to_sigset_t(p, &mask);
+ mask = p->p_siglist;
SIGSETNAND(mask, p->p_sigmask);
if (p->p_flag & P_PPWAIT)
SIG_STOPSIGMASK(mask);
if (SIGISEMPTY(mask)) /* no signal to send */
return (0);
- sig = signal_queued_mask(p, mask);
+ sig = sig_ffs(&mask);
prop = sigprop(sig);
_STOPEVENT(p, S_SIG, sig);
@@ -1633,7 +1625,7 @@ issignal(td)
* only if P_TRACED was on when they were posted.
*/
if (SIGISMEMBER(p->p_sigignore, sig) && (traced == 0)) {
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
continue;
}
if (p->p_flag & P_TRACED && (p->p_flag & P_PPWAIT) == 0) {
@@ -1668,16 +1660,16 @@ issignal(td)
* then it will leave it in p->p_xstat;
* otherwise we just look for signals again.
*/
- signal_delete(p, NULL, sig); /* clear old signal */
+ SIGDELSET(p->p_siglist, sig); /* clear old signal */
sig = p->p_xstat;
if (sig == 0)
continue;
/*
- * Put the new signal into p_sigq. If the signal
- * is being masked, look for other signals.
+ * Put the new signal into p_siglist. If the
+ * signal is being masked, look for other signals.
*/
- psignal(p, sig);
+ SIGADDSET(p->p_siglist, sig);
if (SIGISMEMBER(p->p_sigmask, sig))
continue;
signotify(p);
@@ -1767,7 +1759,7 @@ issignal(td)
*/
return (sig);
}
- signal_delete(p, NULL, sig); /* take the signal! */
+ SIGDELSET(p->p_siglist, sig); /* take the signal! */
}
/* NOTREACHED */
}
@@ -1808,7 +1800,7 @@ postsig(sig)
PROC_LOCK_ASSERT(p, MA_OWNED);
ps = p->p_sigacts;
- signal_delete(p, NULL, sig);
+ SIGDELSET(p->p_siglist, sig);
action = ps->ps_sigact[_SIG_IDX(sig)];
#ifdef KTRACE
if (KTRPOINT(td, KTR_PSIG))