summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>1999-09-29 15:03:48 +0000
committermarcel <marcel@FreeBSD.org>1999-09-29 15:03:48 +0000
commitd5e8d714b93b1824409b762780bec45541995276 (patch)
tree6c8b2043aa3edb629a1ac31d0703f667667a8072
parenta77a86a32324d1cd4c2f1b3055c97e6bc066a6eb (diff)
downloadFreeBSD-src-d5e8d714b93b1824409b762780bec45541995276.zip
FreeBSD-src-d5e8d714b93b1824409b762780bec45541995276.tar.gz
sigset_t change (part 2 of 5)
----------------------------- The core of the signalling code has been rewritten to operate on the new sigset_t. No methodological changes have been made. Most references to a sigset_t object are through macros (see signalvar.h) to create a level of abstraction and to provide a basis for further improvements. The NSIG constant has not been changed to reflect the maximum number of signals possible. The reason is that it breaks programs (especially shells) which assume that all signals have a non-null name in sys_signame. See src/bin/sh/trap.c for an example. Instead _SIG_MAXSIG has been introduced to hold the maximum signal possible with the new sigset_t. struct sigprop has been moved from signalvar.h to kern_sig.c because a) it is only used there, and b) access must be done though function sigprop(). The latter because the table doesn't holds properties for all signals, but only for the first NSIG signals. signal.h has been reorganized to make reading easier and to add the new and/or modified structures. The "old" structures are moved to signalvar.h to prevent namespace polution. Especially the coda filesystem suffers from the change, because it contained lines like (p->p_sigmask == SIGIO), which is easy to do for integral types, but not for compound types. NOTE: kdump (and port linux_kdump) must be recompiled. Thanks to Garrett Wollman and Daniel Eischen for pressing the importance of changing sigreturn as well.
-rw-r--r--sys/coda/coda_psdev.c73
-rw-r--r--sys/fs/coda/coda_psdev.c73
-rw-r--r--sys/fs/procfs/procfs_ctl.c2
-rw-r--r--sys/kern/init_sysent.c19
-rw-r--r--sys/kern/kern_exit.c2
-rw-r--r--sys/kern/kern_ktrace.c6
-rw-r--r--sys/kern/kern_sig.c893
-rw-r--r--sys/kern/kern_synch.c4
-rw-r--r--sys/kern/syscalls.c19
-rw-r--r--sys/kern/tty.c28
-rw-r--r--sys/kern/tty_pty.c7
-rw-r--r--sys/miscfs/procfs/procfs_ctl.c2
-rw-r--r--sys/nfs/nfs.h6
-rw-r--r--sys/nfs/nfs_socket.c9
-rw-r--r--sys/nfsclient/nfs.h6
-rw-r--r--sys/nfsclient/nfs_socket.c9
-rw-r--r--sys/nfsclient/nfsargs.h6
-rw-r--r--sys/nfsclient/nfsstats.h6
-rw-r--r--sys/nfsserver/nfs.h6
-rw-r--r--sys/nfsserver/nfs_srvsock.c9
-rw-r--r--sys/nfsserver/nfsrvstats.h6
-rw-r--r--sys/sys/_sigset.h225
-rw-r--r--sys/sys/ktrace.h4
-rw-r--r--sys/sys/param.h2
-rw-r--r--sys/sys/proc.h3
-rw-r--r--sys/sys/signal.h225
-rw-r--r--sys/sys/signalvar.h222
-rw-r--r--sys/sys/syscall-hide.h17
-rw-r--r--sys/sys/syscall.h19
-rw-r--r--sys/sys/syscall.mk19
-rw-r--r--sys/sys/sysent.h4
-rw-r--r--sys/sys/sysproto.h60
-rw-r--r--sys/sys/ucontext.h44
-rw-r--r--sys/ufs/mfs/mfs_vfsops.c9
34 files changed, 1263 insertions, 781 deletions
diff --git a/sys/coda/coda_psdev.c b/sys/coda/coda_psdev.c
index 520702b..4cd559d 100644
--- a/sys/coda/coda_psdev.c
+++ b/sys/coda/coda_psdev.c
@@ -75,6 +75,10 @@ extern int coda_nc_initialized; /* Set if cache has been initialized */
#define CTL_C
+#ifdef CTL_C
+#include <sys/signalvar.h>
+#endif
+
int coda_psdev_print_entry = 0;
static
int outstanding_upcalls = 0;
@@ -485,7 +489,8 @@ coda_call(mntinfo, inSize, outSize, buffer)
int error;
#ifdef CTL_C
struct proc *p = curproc;
- unsigned int psig_omask = p->p_sigmask;
+ sigset_t psig_omask = p->p_sigmask;
+ sigset_t tempset;
int i;
#endif
if (mntinfo == NULL) {
@@ -541,36 +546,56 @@ coda_call(mntinfo, inSize, outSize, buffer)
*/
i = 0;
do {
- error = tsleep(&vmp->vm_sleep, (coda_call_sleep|coda_pcatch), "coda_call", hz*2);
- if (error == 0)
- break;
- else if (error == EWOULDBLOCK) {
+ error = tsleep(&vmp->vm_sleep,
+ (coda_call_sleep|coda_pcatch), "coda_call",
+ hz*2);
+ if (error == 0)
+ break;
+ else if (error == EWOULDBLOCK) {
#ifdef CODA_VERBOSE
- printf("coda_call: tsleep TIMEOUT %d sec\n", 2+2*i);
+ printf("coda_call: tsleep TIMEOUT %d sec\n", 2+2*i);
#endif
- } else if (p->p_siglist == sigmask(SIGIO)) {
- p->p_sigmask |= p->p_siglist;
+ }
+ else {
+ SIGEMPTYSET(tempset);
+ SIGADDSET(tempset, SIGIO);
+ if (SIGSETEQ(p->p_siglist, tempset)) {
+ SIGADDSET(p->p_sigmask, SIGIO);
#ifdef CODA_VERBOSE
- printf("coda_call: tsleep returns %d SIGIO, cnt %d\n", error, i);
+ printf("coda_call: tsleep returns %d SIGIO, cnt %d\n",
+ error, i);
#endif
- } else if (p->p_siglist == sigmask(SIGALRM)) {
- p->p_sigmask |= p->p_siglist;
+ } else {
+ SIGDELSET(tempset, SIGIO);
+ SIGADDSET(tempset, SIGALRM);
+ if (SIGSETEQ(p->p_siglist, tempset)) {
+ SIGADDSET(p->p_sigmask, SIGALRM);
#ifdef CODA_VERBOSE
- printf("coda_call: tsleep returns %d SIGALRM, cnt %d\n", error, i);
+ printf("coda_call: tsleep returns %d SIGALRM, cnt %d\n",
+ error, i);
#endif
- } else {
- printf("coda_call: tsleep returns %d, cnt %d\n", error, i);
- printf("coda_call: siglist = %x, sigmask = %x, mask %x\n",
- p->p_siglist, p->p_sigmask,
- p->p_siglist & ~p->p_sigmask);
- break;
-#ifdef notyet
- p->p_sigmask |= p->p_siglist;
- printf("coda_call: new mask, siglist = %x, sigmask = %x, mask %x\n",
- p->p_siglist, p->p_sigmask,
- p->p_siglist & ~p->p_sigmask);
+ }
+ else {
+ printf("coda_call: tsleep returns %d, cnt %d\n",
+ error, i);
+
+#if notyet
+ tempset = p->p_siglist;
+ SIGSETNAND(tempset, p->p_sigmask);
+ printf("coda_call: siglist = %p, sigmask = %p, mask %p\n",
+ p->p_siglist, p->p_sigmask,
+ tempset);
+ break;
+ SIGSETOR(p->p_sigmask, p->p_siglist);
+ tempset = p->p_siglist;
+ SIGSETNAND(tempset, p->p_sigmask);
+ printf("coda_call: new mask, siglist = %p, sigmask = %p, mask %p\n",
+ p->p_siglist, p->p_sigmask,
+ tempset);
#endif
- }
+ }
+ }
+ }
} while (error && i++ < 128 && VC_OPEN(vcp));
p->p_sigmask = psig_omask;
#else
diff --git a/sys/fs/coda/coda_psdev.c b/sys/fs/coda/coda_psdev.c
index 520702b..4cd559d 100644
--- a/sys/fs/coda/coda_psdev.c
+++ b/sys/fs/coda/coda_psdev.c
@@ -75,6 +75,10 @@ extern int coda_nc_initialized; /* Set if cache has been initialized */
#define CTL_C
+#ifdef CTL_C
+#include <sys/signalvar.h>
+#endif
+
int coda_psdev_print_entry = 0;
static
int outstanding_upcalls = 0;
@@ -485,7 +489,8 @@ coda_call(mntinfo, inSize, outSize, buffer)
int error;
#ifdef CTL_C
struct proc *p = curproc;
- unsigned int psig_omask = p->p_sigmask;
+ sigset_t psig_omask = p->p_sigmask;
+ sigset_t tempset;
int i;
#endif
if (mntinfo == NULL) {
@@ -541,36 +546,56 @@ coda_call(mntinfo, inSize, outSize, buffer)
*/
i = 0;
do {
- error = tsleep(&vmp->vm_sleep, (coda_call_sleep|coda_pcatch), "coda_call", hz*2);
- if (error == 0)
- break;
- else if (error == EWOULDBLOCK) {
+ error = tsleep(&vmp->vm_sleep,
+ (coda_call_sleep|coda_pcatch), "coda_call",
+ hz*2);
+ if (error == 0)
+ break;
+ else if (error == EWOULDBLOCK) {
#ifdef CODA_VERBOSE
- printf("coda_call: tsleep TIMEOUT %d sec\n", 2+2*i);
+ printf("coda_call: tsleep TIMEOUT %d sec\n", 2+2*i);
#endif
- } else if (p->p_siglist == sigmask(SIGIO)) {
- p->p_sigmask |= p->p_siglist;
+ }
+ else {
+ SIGEMPTYSET(tempset);
+ SIGADDSET(tempset, SIGIO);
+ if (SIGSETEQ(p->p_siglist, tempset)) {
+ SIGADDSET(p->p_sigmask, SIGIO);
#ifdef CODA_VERBOSE
- printf("coda_call: tsleep returns %d SIGIO, cnt %d\n", error, i);
+ printf("coda_call: tsleep returns %d SIGIO, cnt %d\n",
+ error, i);
#endif
- } else if (p->p_siglist == sigmask(SIGALRM)) {
- p->p_sigmask |= p->p_siglist;
+ } else {
+ SIGDELSET(tempset, SIGIO);
+ SIGADDSET(tempset, SIGALRM);
+ if (SIGSETEQ(p->p_siglist, tempset)) {
+ SIGADDSET(p->p_sigmask, SIGALRM);
#ifdef CODA_VERBOSE
- printf("coda_call: tsleep returns %d SIGALRM, cnt %d\n", error, i);
+ printf("coda_call: tsleep returns %d SIGALRM, cnt %d\n",
+ error, i);
#endif
- } else {
- printf("coda_call: tsleep returns %d, cnt %d\n", error, i);
- printf("coda_call: siglist = %x, sigmask = %x, mask %x\n",
- p->p_siglist, p->p_sigmask,
- p->p_siglist & ~p->p_sigmask);
- break;
-#ifdef notyet
- p->p_sigmask |= p->p_siglist;
- printf("coda_call: new mask, siglist = %x, sigmask = %x, mask %x\n",
- p->p_siglist, p->p_sigmask,
- p->p_siglist & ~p->p_sigmask);
+ }
+ else {
+ printf("coda_call: tsleep returns %d, cnt %d\n",
+ error, i);
+
+#if notyet
+ tempset = p->p_siglist;
+ SIGSETNAND(tempset, p->p_sigmask);
+ printf("coda_call: siglist = %p, sigmask = %p, mask %p\n",
+ p->p_siglist, p->p_sigmask,
+ tempset);
+ break;
+ SIGSETOR(p->p_sigmask, p->p_siglist);
+ tempset = p->p_siglist;
+ SIGSETNAND(tempset, p->p_sigmask);
+ printf("coda_call: new mask, siglist = %p, sigmask = %p, mask %p\n",
+ p->p_siglist, p->p_sigmask,
+ tempset);
#endif
- }
+ }
+ }
+ }
} while (error && i++ < 128 && VC_OPEN(vcp));
p->p_sigmask = psig_omask;
#else
diff --git a/sys/fs/procfs/procfs_ctl.c b/sys/fs/procfs/procfs_ctl.c
index 4f4d84b..9a74aa3 100644
--- a/sys/fs/procfs/procfs_ctl.c
+++ b/sys/fs/procfs/procfs_ctl.c
@@ -192,7 +192,7 @@ procfs_control(curp, p, op)
p->p_flag &= ~P_TRACED;
/* remove pending SIGTRAP, else the process will die */
- p->p_siglist &= ~sigmask (SIGTRAP);
+ SIGDELSET(p->p_siglist, SIGTRAP);
/* give process back to original parent */
if (p->p_oppid != p->p_pptr->p_pid) {
diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c
index 05f81f7..e135090 100644
--- a/sys/kern/init_sysent.c
+++ b/sys/kern/init_sysent.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.64 1999/09/11 00:45:58 alfred Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.65 1999/09/29 15:01:21 marcel Exp
*/
#include "opt_compat.h"
@@ -66,13 +66,13 @@ struct sysent sysent[] = {
{ 0, (sy_call_t *)getegid }, /* 43 = getegid */
{ 4, (sy_call_t *)profil }, /* 44 = profil */
{ 4, (sy_call_t *)ktrace }, /* 45 = ktrace */
- { 3, (sy_call_t *)sigaction }, /* 46 = sigaction */
+ { 3, (sy_call_t *)osigaction }, /* 46 = osigaction */
{ 0, (sy_call_t *)getgid }, /* 47 = getgid */
- { 2, (sy_call_t *)sigprocmask }, /* 48 = sigprocmask */
+ { 2, (sy_call_t *)osigprocmask }, /* 48 = osigprocmask */
{ 2, (sy_call_t *)getlogin }, /* 49 = getlogin */
{ 1, (sy_call_t *)setlogin }, /* 50 = setlogin */
{ 1, (sy_call_t *)acct }, /* 51 = acct */
- { 0, (sy_call_t *)sigpending }, /* 52 = sigpending */
+ { 0, (sy_call_t *)osigpending }, /* 52 = osigpending */
{ 2, (sy_call_t *)sigaltstack }, /* 53 = sigaltstack */
{ 3, (sy_call_t *)ioctl }, /* 54 = ioctl */
{ 1, (sy_call_t *)reboot }, /* 55 = reboot */
@@ -123,7 +123,7 @@ struct sysent sysent[] = {
{ 2, (sy_call_t *)getpriority }, /* 100 = getpriority */
{ compat(4,send) }, /* 101 = old send */
{ compat(4,recv) }, /* 102 = old recv */
- { 1, (sy_call_t *)sigreturn }, /* 103 = sigreturn */
+ { 1, (sy_call_t *)osigreturn }, /* 103 = osigreturn */
{ 3, (sy_call_t *)bind }, /* 104 = bind */
{ 5, (sy_call_t *)setsockopt }, /* 105 = setsockopt */
{ 2, (sy_call_t *)listen }, /* 106 = listen */
@@ -131,7 +131,7 @@ struct sysent sysent[] = {
{ compat(3,sigvec) }, /* 108 = old sigvec */
{ compat(1,sigblock) }, /* 109 = old sigblock */
{ compat(1,sigsetmask) }, /* 110 = old sigsetmask */
- { 1, (sy_call_t *)sigsuspend }, /* 111 = sigsuspend */
+ { 1, (sy_call_t *)osigsuspend }, /* 111 = osigsuspend */
{ compat(2,sigstack) }, /* 112 = old sigstack */
{ compat(3,recvmsg) }, /* 113 = old recvmsg */
{ compat(3,sendmsg) }, /* 114 = old sendmsg */
@@ -360,4 +360,11 @@ struct sysent sysent[] = {
{ 3, (sy_call_t *)kldsym }, /* 337 = kldsym */
{ 1, (sy_call_t *)jail }, /* 338 = jail */
{ 0, (sy_call_t *)nosys }, /* 339 = pioctl */
+ { 3, (sy_call_t *)sigprocmask }, /* 340 = sigprocmask */
+ { 1, (sy_call_t *)sigsuspend }, /* 341 = sigsuspend */
+ { 3, (sy_call_t *)sigaction }, /* 342 = sigaction */
+ { 1, (sy_call_t *)sigpending }, /* 343 = sigpending */
+ { 1, (sy_call_t *)sigreturn }, /* 344 = sigreturn */
+ { 0, (sy_call_t *)nosys }, /* 345 = sigtimedwait */
+ { 0, (sy_call_t *)nosys }, /* 346 = sigwaitinfo */
};
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 50e29b8..acdc299 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -173,7 +173,7 @@ exit1(p, rv)
*/
p->p_flag &= ~(P_TRACED | P_PPWAIT);
p->p_flag |= P_WEXIT;
- p->p_siglist = 0;
+ SIGEMPTYSET(p->p_siglist);
if (timevalisset(&p->p_realtimer.it_value))
untimeout(realitexpire, (caddr_t)p, p->p_ithandle);
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index 46691a0..c2dfcac 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -194,9 +194,9 @@ done:
void
ktrpsig(vp, sig, action, mask, code)
struct vnode *vp;
- int sig;
+ int sig, code;
sig_t action;
- int mask, code;
+ sigset_t *mask;
{
struct ktr_header *kth;
struct ktr_psig kp;
@@ -206,7 +206,7 @@ ktrpsig(vp, sig, action, mask, code)
kth = ktrgetheader(KTR_PSIG);
kp.signo = (char)sig;
kp.action = action;
- kp.mask = mask;
+ kp.mask = *mask;
kp.code = code;
kth->ktr_buf = (caddr_t)&kp;
kth->ktr_len = sizeof (struct ktr_psig);
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index b340287..3d3aaba 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -42,7 +42,6 @@
#include "opt_compat.h"
#include "opt_ktrace.h"
-#define SIGPROP /* include signal properties table */
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/sysproto.h>
@@ -68,8 +67,13 @@
#include <machine/smp.h>
#endif
-static int killpg1 __P((struct proc *cp, int signum, int pgid, int all));
-static void setsigvec __P((struct proc *p, int signum, struct sigaction *sa));
+static int sigprop __P((int sig));
+static int sig_ffs __P((sigset_t *set));
+static int killpg1 __P((struct proc *cp, int sig, int pgid, int all));
+static int do_sigaction __P((struct proc *p, int sig, struct sigaction *act,
+ struct sigaction *oact));
+static int do_sigprocmask __P((struct proc *p, int how, sigset_t *set,
+ sigset_t *oset));
static void stop __P((struct proc *));
static char *expand_name __P((const char *, uid_t, pid_t));
static int coredump __P((struct proc *));
@@ -80,15 +84,15 @@ SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW,
"Log processes quitting on abnormal signals to syslog(3)");
/*
- * Can process p, with pcred pc, send the signal signum to process q?
+ * Can process p, with pcred pc, send the signal sig to process q?
*/
-#define CANSIGNAL(p, pc, q, signum) \
+#define CANSIGNAL(p, pc, q, sig) \
(PRISON_CHECK(p, q) && ((pc)->pc_ucred->cr_uid == 0 || \
(pc)->p_ruid == (q)->p_cred->p_ruid || \
(pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \
(pc)->p_ruid == (q)->p_ucred->cr_uid || \
(pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \
- ((signum) == SIGCONT && (q)->p_session == (p)->p_session)))
+ ((sig) == SIGCONT && (q)->p_session == (p)->p_session)))
/*
* Policy -- Can real uid ruid with ucred uc send a signal to process q?
@@ -104,11 +108,203 @@ int sugid_coredump;
SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW,
&sugid_coredump, 0, "Enable coredumping set user/group ID processes");
+/*
+ * Signal properties and actions.
+ * The array below categorizes the signals and their default actions
+ * according to the following properties:
+ */
+#define SA_KILL 0x01 /* terminates process by default */
+#define SA_CORE 0x02 /* ditto and coredumps */
+#define SA_STOP 0x04 /* suspend process */
+#define SA_TTYSTOP 0x08 /* ditto, from tty */
+#define SA_IGNORE 0x10 /* ignore by default */
+#define SA_CONT 0x20 /* continue if suspended */
+#define SA_CANTMASK 0x40 /* non-maskable, catchable */
+
+static int sigproptbl[NSIG] = {
+ SA_KILL, /* SIGHUP */
+ SA_KILL, /* SIGINT */
+ SA_KILL|SA_CORE, /* SIGQUIT */
+ SA_KILL|SA_CORE, /* SIGILL */
+ SA_KILL|SA_CORE, /* SIGTRAP */
+ SA_KILL|SA_CORE, /* SIGABRT */
+ SA_KILL|SA_CORE, /* SIGEMT */
+ SA_KILL|SA_CORE, /* SIGFPE */
+ SA_KILL, /* SIGKILL */
+ SA_KILL|SA_CORE, /* SIGBUS */
+ SA_KILL|SA_CORE, /* SIGSEGV */
+ SA_KILL|SA_CORE, /* SIGSYS */
+ SA_KILL, /* SIGPIPE */
+ SA_KILL, /* SIGALRM */
+ SA_KILL, /* SIGTERM */
+ SA_IGNORE, /* SIGURG */
+ SA_STOP, /* SIGSTOP */
+ SA_STOP|SA_TTYSTOP, /* SIGTSTP */
+ SA_IGNORE|SA_CONT, /* SIGCONT */
+ SA_IGNORE, /* SIGCHLD */
+ SA_STOP|SA_TTYSTOP, /* SIGTTIN */
+ SA_STOP|SA_TTYSTOP, /* SIGTTOU */
+ SA_IGNORE, /* SIGIO */
+ SA_KILL, /* SIGXCPU */
+ SA_KILL, /* SIGXFSZ */
+ SA_KILL, /* SIGVTALRM */
+ SA_KILL, /* SIGPROF */
+ SA_IGNORE, /* SIGWINCH */
+ SA_IGNORE, /* SIGINFO */
+ SA_KILL, /* SIGUSR1 */
+ SA_KILL, /* SIGUSR2 */
+};
+
+extern __inline int sigprop(int sig)
+{
+ if (sig > 0 && sig < NSIG)
+ return (sigproptbl[_SIG_IDX(sig)]);
+ else
+ return (0);
+}
+
+extern __inline int sig_ffs(sigset_t *set)
+{
+ int i;
+
+ for (i = 0; i < _SIG_WORDS; i++) {
+ if (set->__bits[i])
+ return (ffs(set->__bits[i]) + (i * 32));
+ }
+ return (0);
+}
+
+/*
+ * do_sigaction
+ * sigaction
+ * osigaction
+ */
+static int
+do_sigaction(p, sig, act, oact)
+ struct proc *p;
+ register int sig;
+ struct sigaction *act, *oact;
+{
+ register struct sigacts *ps = p->p_sigacts;
+
+ if (sig <= 0 || sig > _SIG_MAXSIG)
+ return (EINVAL);
+
+ if (oact) {
+ oact->sa_handler = ps->ps_sigact[_SIG_IDX(sig)];
+ oact->sa_mask = ps->ps_catchmask[_SIG_IDX(sig)];
+ oact->sa_flags = 0;
+ if (SIGISMEMBER(ps->ps_sigonstack, sig))
+ oact->sa_flags |= SA_ONSTACK;
+ if (!SIGISMEMBER(ps->ps_sigintr, sig))
+ oact->sa_flags |= SA_RESTART;
+ if (SIGISMEMBER(ps->ps_sigreset, sig))
+ oact->sa_flags |= SA_RESETHAND;
+ if (SIGISMEMBER(ps->ps_signodefer, sig))
+ oact->sa_flags |= SA_NODEFER;
+ if (SIGISMEMBER(ps->ps_siginfo, sig))
+ oact->sa_flags |= SA_SIGINFO;
+ if (sig == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP)
+ oact->sa_flags |= SA_NOCLDSTOP;
+ if (sig == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDWAIT)
+ oact->sa_flags |= SA_NOCLDWAIT;
+ }
+ if (act) {
+ if ((sig == SIGKILL || sig == SIGSTOP) &&
+ act->sa_handler != SIG_DFL)
+ return (EINVAL);
+
+ /*
+ * Change setting atomically.
+ */
+ (void) splhigh();
+
+ ps->ps_catchmask[_SIG_IDX(sig)] = act->sa_mask;
+ SIG_CANTMASK(ps->ps_catchmask[_SIG_IDX(sig)]);
+ if (act->sa_flags & SA_SIGINFO) {
+ ps->ps_sigact[_SIG_IDX(sig)] = act->sa_handler;
+ SIGADDSET(ps->ps_siginfo, sig);
+ }
+ else {
+ ps->ps_sigact[_SIG_IDX(sig)] =
+ (__sighandler_t *)act->sa_sigaction;
+ SIGDELSET(ps->ps_siginfo, sig);
+ }
+ if (!(act->sa_flags & SA_RESTART))
+ SIGADDSET(ps->ps_sigintr, sig);
+ else
+ SIGDELSET(ps->ps_sigintr, sig);
+ if (act->sa_flags & SA_ONSTACK)
+ SIGADDSET(ps->ps_sigonstack, sig);
+ else
+ SIGDELSET(ps->ps_sigonstack, sig);
+ if (act->sa_flags & SA_RESETHAND)
+ SIGADDSET(ps->ps_sigreset, sig);
+ else
+ SIGDELSET(ps->ps_sigreset, sig);
+ if (act->sa_flags & SA_NODEFER)
+ SIGADDSET(ps->ps_signodefer, sig);
+ else
+ SIGDELSET(ps->ps_signodefer, sig);
+#ifdef COMPAT_SUNOS
+ if (act->sa_flags & SA_USERTRAMP)
+ SIGADDSET(ps->ps_usertramp, sig);
+ else
+ SIGDELSET(ps->ps_usertramp, seg);
+#endif
+ if (sig == SIGCHLD) {
+ if (act->sa_flags & SA_NOCLDSTOP)
+ p->p_procsig->ps_flag |= P_NOCLDSTOP;
+ else
+ p->p_procsig->ps_flag &= ~P_NOCLDSTOP;
+ if (act->sa_flags & SA_NOCLDWAIT) {
+ /*
+ * Paranoia: since SA_NOCLDWAIT is implemented
+ * by reparenting the dying child to PID 1 (and
+ * trust it to reap the zombie), PID 1 itself
+ * is forbidden to set SA_NOCLDWAIT.
+ */
+ if (p->p_pid == 1)
+ p->p_procsig->ps_flag &= ~P_NOCLDWAIT;
+ else
+ p->p_procsig->ps_flag |= P_NOCLDWAIT;
+ } else
+ p->p_procsig->ps_flag &= ~P_NOCLDWAIT;
+ }
+ /*
+ * Set bit in p_sigignore for signals that are set to SIG_IGN,
+ * and for signals set to SIG_DFL where the default is to
+ * ignore. However, don't put SIGCONT in p_sigignore, as we
+ * have to restart the process.
+ */
+ if (ps->ps_sigact[_SIG_IDX(sig)] == SIG_IGN ||
+ (sigprop(sig) & SA_IGNORE &&
+ ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL)) {
+ /* never to be seen again */
+ SIGDELSET(p->p_siglist, sig);
+ if (sig != SIGCONT)
+ /* easier in psignal */
+ SIGADDSET(p->p_sigignore, sig);
+ SIGDELSET(p->p_sigcatch, sig);
+ }
+ else {
+ SIGDELSET(p->p_sigignore, sig);
+ if (ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL)
+ SIGDELSET(p->p_sigcatch, sig);
+ else
+ SIGADDSET(p->p_sigcatch, sig);
+ }
+
+ (void) spl0();
+ }
+ return (0);
+}
+
#ifndef _SYS_SYSPROTO_H_
struct sigaction_args {
- int signum;
- struct sigaction *nsa;
- struct sigaction *osa;
+ int sig;
+ struct sigaction *act;
+ struct sigaction *oact;
};
#endif
/* ARGSUSED */
@@ -117,138 +313,64 @@ sigaction(p, uap)
struct proc *p;
register struct sigaction_args *uap;
{
- struct sigaction vec;
- register struct sigaction *sa;
- register struct sigacts *ps = p->p_sigacts;
- register int signum;
- int bit, error;
+ struct sigaction act, oact;
+ register struct sigaction *actp, *oactp;
+ int error;
- signum = uap->signum;
- if (signum <= 0 || signum >= NSIG)
- return (EINVAL);
- sa = &vec;
- if (uap->osa) {
- bit = sigmask(signum);
- if ((ps->ps_siginfo & bit) != 0)
- sa->sa_sigaction =
- (__siginfohandler_t *)ps->ps_sigact[signum];
- else
- sa->sa_handler = ps->ps_sigact[signum];
- sa->sa_mask = ps->ps_catchmask[signum];
- sa->sa_flags = 0;
- if ((ps->ps_sigonstack & bit) != 0)
- sa->sa_flags |= SA_ONSTACK;
- if ((ps->ps_sigintr & bit) == 0)
- sa->sa_flags |= SA_RESTART;
- if ((ps->ps_sigreset & bit) != 0)
- sa->sa_flags |= SA_RESETHAND;
- if ((ps->ps_signodefer & bit) != 0)
- sa->sa_flags |= SA_NODEFER;
- if ((ps->ps_siginfo & bit) != 0)
- sa->sa_flags |= SA_SIGINFO;
- if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP)
- sa->sa_flags |= SA_NOCLDSTOP;
- if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDWAIT)
- sa->sa_flags |= SA_NOCLDWAIT;
- if ((error = copyout((caddr_t)sa, (caddr_t)uap->osa,
- sizeof (vec))))
+ p->p_flag |= P_NEWSIGSET;
+
+ actp = (uap->act) ? &act : NULL;
+ oactp = (uap->oact) ? &oact : NULL;
+ if (actp) {
+ error = copyin((c_caddr_t)uap->act, (caddr_t)actp,
+ sizeof(act));
+ if (error)
return (error);
}
- if (uap->nsa) {
- if ((error = copyin((caddr_t)uap->nsa, (caddr_t)sa,
- sizeof (vec))))
- return (error);
- if ((signum == SIGKILL || signum == SIGSTOP) &&
- sa->sa_handler != SIG_DFL)
- return (EINVAL);
- setsigvec(p, signum, sa);
+ error = do_sigaction(p, uap->sig, actp, oactp);
+ if (oactp && !error) {
+ error = copyout((caddr_t)oactp, (caddr_t)uap->oact,
+ sizeof(oact));
}
- return (0);
+ return (error);
}
-static void
-setsigvec(p, signum, sa)
- register struct proc *p;
- int signum;
- register struct sigaction *sa;
+#ifndef _SYS_SYSPROTO_H_
+struct osigaction_args {
+ int signum;
+ struct osigaction *nsa;
+ struct osigaction *osa;
+};
+#endif
+/* ARGSUSED */
+int
+osigaction(p, uap)
+ struct proc *p;
+ register struct osigaction_args *uap;
{
- register struct sigacts *ps = p->p_sigacts;
- register int bit;
+ struct osigaction sa;
+ struct sigaction nsa, osa;
+ register struct sigaction *nsap, *osap;
+ int error;
- bit = sigmask(signum);
- /*
- * Change setting atomically.
- */
- (void) splhigh();
- ps->ps_catchmask[signum] = sa->sa_mask &~ sigcantmask;
- if (sa->sa_flags & SA_SIGINFO) {
- ps->ps_sigact[signum] = sa->sa_handler;
- ps->ps_siginfo |= bit;
- } else {
- ps->ps_sigact[signum] = (__sighandler_t *)sa->sa_sigaction;
- ps->ps_siginfo &= ~bit;
+ nsap = (uap->nsa) ? &nsa : NULL;
+ osap = (uap->osa) ? &osa : NULL;
+ if (nsap) {
+ error = copyin((caddr_t)uap->nsa, (caddr_t)&sa, sizeof(sa));
+ if (error)
+ return (error);
+ nsap->sa_handler = sa.sa_handler;
+ nsap->sa_flags = sa.sa_flags;
+ OSIG2SIG(sa.sa_mask, nsap->sa_mask);
}
- if ((sa->sa_flags & SA_RESTART) == 0)
- ps->ps_sigintr |= bit;
- else
- ps->ps_sigintr &= ~bit;
- if (sa->sa_flags & SA_ONSTACK)
- ps->ps_sigonstack |= bit;
- else
- ps->ps_sigonstack &= ~bit;
- if (sa->sa_flags & SA_RESETHAND)
- ps->ps_sigreset |= bit;
- else
- ps->ps_sigreset &= ~bit;
- if (sa->sa_flags & SA_NODEFER)
- ps->ps_signodefer |= bit;
- else
- ps->ps_signodefer &= ~bit;
-#ifdef COMPAT_SUNOS
- if (sa->sa_flags & SA_USERTRAMP)
- ps->ps_usertramp |= bit;
- else
- ps->ps_usertramp &= ~bit;
-#endif
- if (signum == SIGCHLD) {
- if (sa->sa_flags & SA_NOCLDSTOP)
- p->p_procsig->ps_flag |= P_NOCLDSTOP;
- else
- p->p_procsig->ps_flag &= ~P_NOCLDSTOP;
- if (sa->sa_flags & SA_NOCLDWAIT) {
- /*
- * Paranoia: since SA_NOCLDWAIT is implemented by
- * reparenting the dying child to PID 1 (and
- * trust it to reap the zombie), PID 1 itself is
- * forbidden to set SA_NOCLDWAIT.
- */
- if (p->p_pid == 1)
- p->p_procsig->ps_flag &= ~P_NOCLDWAIT;
- else
- p->p_procsig->ps_flag |= P_NOCLDWAIT;
- } else
- p->p_procsig->ps_flag &= ~P_NOCLDWAIT;
+ error = do_sigaction(p, uap->signum, nsap, osap);
+ if (osap && !error) {
+ sa.sa_handler = osap->sa_handler;
+ sa.sa_flags = osap->sa_flags;
+ SIG2OSIG(osap->sa_mask, sa.sa_mask);
+ error = copyout((caddr_t)&sa, (caddr_t)uap->osa, sizeof(sa));
}
- /*
- * Set bit in p_sigignore for signals that are set to SIG_IGN,
- * and for signals set to SIG_DFL where the default is to ignore.
- * However, don't put SIGCONT in p_sigignore,
- * as we have to restart the process.
- */
- if (ps->ps_sigact[signum] == SIG_IGN ||
- (sigprop[signum] & SA_IGNORE && ps->ps_sigact[signum] == SIG_DFL)) {
- p->p_siglist &= ~bit; /* never to be seen again */
- if (signum != SIGCONT)
- p->p_sigignore |= bit; /* easier in psignal */
- p->p_sigcatch &= ~bit;
- } else {
- p->p_sigignore &= ~bit;
- if (ps->ps_sigact[signum] == SIG_DFL)
- p->p_sigcatch &= ~bit;
- else
- p->p_sigcatch |= bit;
- }
- (void) spl0();
+ return (error);
}
/*
@@ -261,9 +383,9 @@ siginit(p)
{
register int i;
- for (i = 0; i < NSIG; i++)
- if (sigprop[i] & SA_IGNORE && i != SIGCONT)
- p->p_sigignore |= sigmask(i);
+ for (i = 1; i <= NSIG; i++)
+ if (sigprop(i) & SA_IGNORE && i != SIGCONT)
+ SIGADDSET(p->p_sigignore, i);
}
/*
@@ -274,23 +396,22 @@ execsigs(p)
register struct proc *p;
{
register struct sigacts *ps = p->p_sigacts;
- register int nc, mask;
+ register int sig;
/*
* Reset caught signals. Held signals remain held
* through p_sigmask (unless they were caught,
* and are now ignored by default).
*/
- while (p->p_sigcatch) {
- nc = ffs((long)p->p_sigcatch);
- mask = sigmask(nc);
- p->p_sigcatch &= ~mask;
- if (sigprop[nc] & SA_IGNORE) {
- if (nc != SIGCONT)
- p->p_sigignore |= mask;
- p->p_siglist &= ~mask;
+ while (SIGNOTEMPTY(p->p_sigcatch)) {
+ sig = sig_ffs(&p->p_sigcatch);
+ SIGDELSET(p->p_sigcatch, sig);
+ if (sigprop(sig) & SA_IGNORE) {
+ if (sig != SIGCONT)
+ SIGADDSET(p->p_sigignore, sig);
+ SIGDELSET(p->p_siglist, sig);
}
- ps->ps_sigact[nc] = SIG_DFL;
+ ps->ps_sigact[_SIG_IDX(sig)] = SIG_DFL;
}
/*
* Reset stack state to the user stack.
@@ -312,10 +433,46 @@ execsigs(p)
* and return old mask as return value;
* the library stub does the rest.
*/
+static int
+do_sigprocmask(p, how, set, oset)
+ struct proc *p;
+ int how;
+ sigset_t *set, *oset;
+{
+ int error;
+
+ if (oset != NULL)
+ *oset = p->p_sigmask;
+
+ error = 0;
+ if (set != NULL) {
+ (void) splhigh();
+ switch (how) {
+ case SIG_BLOCK:
+ SIGSETOR(p->p_sigmask, *set);
+ SIG_CANTMASK(p->p_sigmask);
+ break;
+ case SIG_UNBLOCK:
+ SIGSETNAND(p->p_sigmask, *set);
+ break;
+ case SIG_SETMASK:
+ p->p_sigmask = *set;
+ SIG_CANTMASK(p->p_sigmask);
+ break;
+ default:
+ error = EINVAL;
+ break;
+ }
+ (void) spl0();
+ }
+ return (error);
+}
+
#ifndef _SYS_SYSPROTO_H_
struct sigprocmask_args {
int how;
- sigset_t mask;
+ const sigset_t *set;
+ sigset_t *oset;
};
#endif
int
@@ -323,35 +480,49 @@ sigprocmask(p, uap)
register struct proc *p;
struct sigprocmask_args *uap;
{
- int error = 0;
-
- p->p_retval[0] = p->p_sigmask;
- (void) splhigh();
-
- switch (uap->how) {
- case SIG_BLOCK:
- p->p_sigmask |= uap->mask &~ sigcantmask;
- break;
+ sigset_t set, oset;
+ sigset_t *setp, *osetp;
+ int error;
- case SIG_UNBLOCK:
- p->p_sigmask &= ~uap->mask;
- break;
+ setp = (uap->set) ? &set : NULL;
+ osetp = (uap->oset) ? &oset : NULL;
+ if (setp) {
+ error = copyin((c_caddr_t)uap->set, (caddr_t)setp,
+ sizeof(set));
+ if (error)
+ return (error);
+ }
+ error = do_sigprocmask(p, uap->how, setp, osetp);
+ if (osetp && !error) {
+ error = copyout((caddr_t)osetp, (caddr_t)uap->oset,
+ sizeof(oset));
+ }
+ return (error);
+}
- case SIG_SETMASK:
- p->p_sigmask = uap->mask &~ sigcantmask;
- break;
+#ifndef _SYS_SYSPROTO_H_
+struct osigprocmask_args {
+ int how;
+ osigset_t mask;
+};
+#endif
+int
+osigprocmask(p, uap)
+ register struct proc *p;
+ struct osigprocmask_args *uap;
+{
+ sigset_t set, oset;
+ int error;
- default:
- error = EINVAL;
- break;
- }
- (void) spl0();
+ OSIG2SIG(uap->mask, set);
+ error = do_sigprocmask(p, uap->how, &set, &oset);
+ SIG2OSIG(oset, p->p_retval[0]);
return (error);
}
#ifndef _SYS_SYSPROTO_H_
struct sigpending_args {
- int dummy;
+ sigset_t *set;
};
#endif
/* ARGSUSED */
@@ -361,7 +532,23 @@ sigpending(p, uap)
struct sigpending_args *uap;
{
- p->p_retval[0] = p->p_siglist;
+ return (copyout((caddr_t)&p->p_siglist, (caddr_t)uap->set,
+ sizeof(sigset_t)));
+}
+
+#ifndef _SYS_SYSPROTO_H_
+struct osigpending_args {
+ int dummy;
+};
+#endif
+/* ARGSUSED */
+int
+osigpending(p, uap)
+ struct proc *p;
+ struct osigpending_args *uap;
+{
+
+ SIG2OSIG(p->p_siglist, p->p_retval[0]);
return (0);
}
@@ -383,52 +570,37 @@ osigvec(p, uap)
register struct osigvec_args *uap;
{
struct sigvec vec;
- register struct sigacts *ps = p->p_sigacts;
- register struct sigvec *sv;
- register int signum;
- int bit, error;
+ struct sigaction nsa, osa;
+ register struct sigaction *nsap, *osap;
+ int error;
- signum = uap->signum;
- if (signum <= 0 || signum >= NSIG)
- return (EINVAL);
- sv = &vec;
- if (uap->osv) {
- *(sig_t *)&sv->sv_handler = ps->ps_sigact[signum];
- sv->sv_mask = ps->ps_catchmask[signum];
- bit = sigmask(signum);
- sv->sv_flags = 0;
- if ((ps->ps_sigonstack & bit) != 0)
- sv->sv_flags |= SV_ONSTACK;
- if ((ps->ps_sigintr & bit) != 0)
- sv->sv_flags |= SV_INTERRUPT;
- if ((ps->ps_sigreset & bit) != 0)
- sv->sv_flags |= SV_RESETHAND;
- if ((ps->ps_signodefer & bit) != 0)
- sv->sv_flags |= SV_NODEFER;
- if ((ps->ps_siginfo & bit) != 0)
- sv->sv_flags |= SV_SIGINFO;
-#ifndef COMPAT_SUNOS
- if (signum == SIGCHLD && p->p_procsig->ps_flag & P_NOCLDSTOP)
- sv->sv_flags |= SV_NOCLDSTOP;
-#endif
- if ((error = copyout((caddr_t)sv, (caddr_t)uap->osv,
- sizeof (vec))))
+ nsap = (uap->nsv) ? &nsa : NULL;
+ osap = (uap->osv) ? &osa : NULL;
+ if (nsap) {
+ error = copyin((caddr_t)uap->nsv, (caddr_t)&vec, sizeof(vec));
+ if (error)
return (error);
+ nsap->sa_handler = vec.sv_handler;
+ OSIG2SIG(vec.sv_mask, nsap->sa_mask);
+ nsap->sa_flags = vec.sv_flags;
+ nsap->sa_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
+#ifdef COMPAT_SUNOS
+ nsap->sa_flags |= SA_USERTRAMP;
+#endif
}
- if (uap->nsv) {
- if ((error = copyin((caddr_t)uap->nsv, (caddr_t)sv,
- sizeof (vec))))
- return (error);
- if ((signum == SIGKILL || signum == SIGSTOP) &&
- sv->sv_handler != SIG_DFL)
- return (EINVAL);
+ error = do_sigaction(p, uap->signum, nsap, osap);
+ if (osap && !error) {
+ vec.sv_handler = osap->sa_handler;
+ SIG2OSIG(osap->sa_mask, vec.sv_mask);
+ vec.sv_flags = osap->sa_flags;
+ vec.sv_flags &= ~SA_NOCLDWAIT;
+ vec.sv_flags ^= SA_RESTART;
#ifdef COMPAT_SUNOS
- sv->sv_flags |= SA_USERTRAMP;
+ vec.sv_flags &= ~SA_NOCLDSTOP;
#endif
- sv->sv_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
- setsigvec(p, signum, (struct sigaction *)sv);
+ error = copyout((caddr_t)&vec, (caddr_t)uap->osv, sizeof(vec));
}
- return (0);
+ return (error);
}
#ifndef _SYS_SYSPROTO_H_
@@ -441,10 +613,13 @@ osigblock(p, uap)
register struct proc *p;
struct osigblock_args *uap;
{
+ sigset_t set;
+ OSIG2SIG(uap->mask, set);
+ SIG_CANTMASK(set);
(void) splhigh();
- p->p_retval[0] = p->p_sigmask;
- p->p_sigmask |= uap->mask &~ sigcantmask;
+ SIG2OSIG(p->p_sigmask, p->p_retval[0]);
+ SIGSETOR(p->p_sigmask, set);
(void) spl0();
return (0);
}
@@ -459,10 +634,13 @@ osigsetmask(p, uap)
struct proc *p;
struct osigsetmask_args *uap;
{
+ sigset_t set;
+ OSIG2SIG(uap->mask, set);
+ SIG_CANTMASK(set);
(void) splhigh();
- p->p_retval[0] = p->p_sigmask;
- p->p_sigmask = uap->mask &~ sigcantmask;
+ SIG2OSIG(p->p_sigmask, p->p_retval[0]);
+ p->p_sigmask = set;
(void) spl0();
return (0);
}
@@ -475,7 +653,7 @@ osigsetmask(p, uap)
*/
#ifndef _SYS_SYSPROTO_H_
struct sigsuspend_args {
- sigset_t mask;
+ const sigset_t *sigmask;
};
#endif
/* ARGSUSED */
@@ -484,7 +662,13 @@ sigsuspend(p, uap)
register struct proc *p;
struct sigsuspend_args *uap;
{
+ sigset_t mask;
register struct sigacts *ps = p->p_sigacts;
+ int error;
+
+ error = copyin((c_caddr_t)uap->sigmask, (caddr_t)&mask, sizeof(mask));
+ if (error)
+ return (error);
/*
* When returning from sigpause, we want
@@ -494,7 +678,32 @@ sigsuspend(p, uap)
* to indicate this.
*/
p->p_oldsigmask = p->p_sigmask;
- p->p_sigmask = uap->mask &~ sigcantmask;
+ p->p_sigmask = mask;
+ SIG_CANTMASK(p->p_sigmask);
+ while (tsleep((caddr_t) ps, PPAUSE|PCATCH, "pause", 0) == 0)
+ /* void */;
+ /* always return EINTR rather than ERESTART... */
+ return (EINTR);
+}
+
+#ifndef _SYS_SYSPROTO_H_
+struct osigsuspend_args {
+ osigset_t mask;
+};
+#endif
+/* ARGSUSED */
+int
+osigsuspend(p, uap)
+ register struct proc *p;
+ struct osigsuspend_args *uap;
+{
+ sigset_t set;
+ register struct sigacts *ps = p->p_sigacts;
+
+ OSIG2SIG(uap->mask, set);
+ SIG_CANTMASK(set);
+ p->p_oldsigmask = p->p_sigmask;
+ p->p_sigmask = set;
while (tsleep((caddr_t) ps, PPAUSE|PCATCH, "pause", 0) == 0)
/* void */;
/* always return EINTR rather than ERESTART... */
@@ -537,8 +746,8 @@ osigstack(p, uap)
#ifndef _SYS_SYSPROTO_H_
struct sigaltstack_args {
- struct sigaltstack *nss;
- struct sigaltstack *oss;
+ stack_t *ss;
+ stack_t *oss;
};
#endif
/* ARGSUSED */
@@ -548,18 +757,18 @@ sigaltstack(p, uap)
register struct sigaltstack_args *uap;
{
struct sigacts *psp;
- struct sigaltstack ss;
+ stack_t ss;
int error;
psp = p->p_sigacts;
if ((psp->ps_flags & SAS_ALTSTACK) == 0)
psp->ps_sigstk.ss_flags |= SS_DISABLE;
if (uap->oss && (error = copyout((caddr_t)&psp->ps_sigstk,
- (caddr_t)uap->oss, sizeof (struct sigaltstack))))
+ (caddr_t)uap->oss, sizeof (stack_t))))
return (error);
- if (uap->nss == 0)
+ if (uap->ss == 0)
return (0);
- if ((error = copyin((caddr_t)uap->nss, (caddr_t)&ss, sizeof (ss))))
+ if ((error = copyin((caddr_t)uap->ss, (caddr_t)&ss, sizeof (ss))))
return (error);
if (ss.ss_flags & SS_DISABLE) {
if (psp->ps_sigstk.ss_flags & SS_ONSTACK)
@@ -571,7 +780,7 @@ sigaltstack(p, uap)
if (ss.ss_size < MINSIGSTKSZ)
return (ENOMEM);
psp->ps_flags |= SAS_ALTSTACK;
- psp->ps_sigstk= ss;
+ psp->ps_sigstk = ss;
return (0);
}
@@ -580,9 +789,9 @@ sigaltstack(p, uap)
* cp is calling process.
*/
int
-killpg1(cp, signum, pgid, all)
+killpg1(cp, sig, pgid, all)
register struct proc *cp;
- int signum, pgid, all;
+ int sig, pgid, all;
{
register struct proc *p;
register struct pcred *pc = cp->p_cred;
@@ -595,11 +804,11 @@ killpg1(cp, signum, pgid, all)
*/
for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
if (p->p_pid <= 1 || p->p_flag & P_SYSTEM ||
- p == cp || !CANSIGNAL(cp, pc, p, signum))
+ p == cp || !CANSIGNAL(cp, pc, p, sig))
continue;
nfound++;
- if (signum)
- psignal(p, signum);
+ if (sig)
+ psignal(p, sig);
}
else {
if (pgid == 0)
@@ -616,11 +825,11 @@ killpg1(cp, signum, pgid, all)
p = p->p_pglist.le_next) {
if (p->p_pid <= 1 || p->p_flag & P_SYSTEM ||
p->p_stat == SZOMB ||
- !CANSIGNAL(cp, pc, p, signum))
+ !CANSIGNAL(cp, pc, p, sig))
continue;
nfound++;
- if (signum)
- psignal(p, signum);
+ if (sig)
+ psignal(p, sig);
}
}
return (nfound ? 0 : ESRCH);
@@ -641,7 +850,7 @@ kill(cp, uap)
register struct proc *p;
register struct pcred *pc = cp->p_cred;
- if ((u_int)uap->signum >= NSIG)
+ if ((u_int)uap->signum > _SIG_MAXSIG)
return (EINVAL);
if (uap->pid > 0) {
/* kill single process */
@@ -678,7 +887,7 @@ okillpg(p, uap)
register struct okillpg_args *uap;
{
- if ((u_int)uap->signum >= NSIG)
+ if ((u_int)uap->signum > _SIG_MAXSIG)
return (EINVAL);
return (killpg1(p, uap->signum, uap->pgid, 0));
}
@@ -688,13 +897,13 @@ okillpg(p, uap)
* Send a signal to a process group.
*/
void
-gsignal(pgid, signum)
- int pgid, signum;
+gsignal(pgid, sig)
+ int pgid, sig;
{
struct pgrp *pgrp;
if (pgid && (pgrp = pgfind(pgid)))
- pgsignal(pgrp, signum, 0);
+ pgsignal(pgrp, sig, 0);
}
/*
@@ -702,9 +911,9 @@ gsignal(pgid, signum)
* limit to members which have a controlling terminal.
*/
void
-pgsignal(pgrp, signum, checkctty)
+pgsignal(pgrp, sig, checkctty)
struct pgrp *pgrp;
- int signum, checkctty;
+ int sig, checkctty;
{
register struct proc *p;
@@ -712,7 +921,7 @@ pgsignal(pgrp, signum, checkctty)
for (p = pgrp->pg_members.lh_first; p != 0;
p = p->p_pglist.le_next)
if (checkctty == 0 || p->p_flag & P_CONTROLT)
- psignal(p, signum);
+ psignal(p, sig);
}
/*
@@ -721,40 +930,41 @@ pgsignal(pgrp, signum, checkctty)
* Otherwise, post it normally.
*/
void
-trapsignal(p, signum, code)
+trapsignal(p, sig, code)
struct proc *p;
- register int signum;
+ register int sig;
u_long code;
{
register struct sigacts *ps = p->p_sigacts;
- int mask;
- mask = sigmask(signum);
- if ((p->p_flag & P_TRACED) == 0 && (p->p_sigcatch & mask) != 0 &&
- (p->p_sigmask & mask) == 0) {
+ if ((p->p_flag & P_TRACED) == 0 && SIGISMEMBER(p->p_sigcatch, sig) &&
+ SIGISMEMBER(p->p_sigmask, sig)) {
p->p_stats->p_ru.ru_nsignals++;
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
- ktrpsig(p->p_tracep, signum, ps->ps_sigact[signum],
- p->p_sigmask, code);
+ ktrpsig(p->p_tracep, sig, ps->ps_sigact[_SIG_IDX(sig)],
+ &p->p_sigmask, code);
#endif
- (*p->p_sysent->sv_sendsig)(ps->ps_sigact[signum], signum,
- p->p_sigmask, code);
- p->p_sigmask |= ps->ps_catchmask[signum] |
- (mask & ~ps->ps_signodefer);
- if ((ps->ps_sigreset & mask) != 0) {
+ (*p->p_sysent->sv_sendsig)(ps->ps_sigact[_SIG_IDX(sig)], sig,
+ &p->p_sigmask, code);
+ SIGSETOR(p->p_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
+ if (!SIGISMEMBER(ps->ps_signodefer, sig))
+ SIGADDSET(p->p_sigmask, sig);
+ if (SIGISMEMBER(ps->ps_sigreset, sig)) {
/*
- * See setsigvec() for origin of this code.
+ * See do_sigaction() for origin of this code.
*/
- p->p_sigcatch &= ~mask;
- if (signum != SIGCONT && sigprop[signum] & SA_IGNORE)
- p->p_sigignore |= mask;
- ps->ps_sigact[signum] = SIG_DFL;
+ SIGDELSET(p->p_sigcatch, sig);
+ if (sig != SIGCONT &&
+ sigprop(sig) & SA_IGNORE)
+ SIGADDSET(p->p_sigignore, sig);
+ ps->ps_sigact[_SIG_IDX(sig)] = SIG_DFL;
}
- } else {
+ }
+ else {
p->p_code = code; /* XXX for core dump/debugger */
- p->p_sig = signum; /* XXX to verify code */
- psignal(p, signum);
+ p->p_sig = sig; /* XXX to verify code */
+ psignal(p, sig);
}
}
@@ -772,20 +982,19 @@ trapsignal(p, signum, code)
* Other ignored signals are discarded immediately.
*/
void
-psignal(p, signum)
+psignal(p, sig)
register struct proc *p;
- register int signum;
+ register int sig;
{
register int s, prop;
register sig_t action;
- int mask;
- if ((u_int)signum >= NSIG || signum == 0) {
- printf("psignal: signum %d\n", signum);
+ if (sig > _SIG_MAXSIG || sig <= 0) {
+ printf("psignal: signal %d\n", sig);
panic("psignal signal number");
}
- mask = sigmask(signum);
- prop = sigprop[signum];
+
+ prop = sigprop(sig);
/*
* If proc is traced, always give parent a chance;
@@ -802,11 +1011,11 @@ psignal(p, signum)
* and if it is set to SIG_IGN,
* action will be SIG_DFL here.)
*/
- if ((p->p_sigignore & mask) || (p->p_flag & P_WEXIT))
+ if (SIGISMEMBER(p->p_sigignore, sig) || (p->p_flag & P_WEXIT))
return;
- if (p->p_sigmask & mask)
+ if (SIGISMEMBER(p->p_sigmask, sig))
action = SIG_HOLD;
- else if (p->p_sigcatch & mask)
+ else if (SIGISMEMBER(p->p_sigcatch, sig))
action = SIG_CATCH;
else
action = SIG_DFL;
@@ -817,7 +1026,7 @@ psignal(p, signum)
p->p_nice = NZERO;
if (prop & SA_CONT)
- p->p_siglist &= ~stopsigmask;
+ SIG_STOPSIGMASK(p->p_siglist);
if (prop & SA_STOP) {
/*
@@ -829,15 +1038,15 @@ psignal(p, signum)
if (prop & SA_TTYSTOP && p->p_pgrp->pg_jobc == 0 &&
action == SIG_DFL)
return;
- p->p_siglist &= ~contsigmask;
+ SIG_CONTSIGMASK(p->p_siglist);
}
- p->p_siglist |= mask;
+ SIGADDSET(p->p_siglist, sig);
/*
* Defer further processing for signals which are held,
* except that stopped processes must be continued by SIGCONT.
*/
- if (action == SIG_HOLD && ((prop & SA_CONT) == 0 || p->p_stat != SSTOP))
+ if (action == SIG_HOLD && (!(prop & SA_CONT) || p->p_stat != SSTOP))
return;
s = splhigh();
switch (p->p_stat) {
@@ -864,7 +1073,7 @@ psignal(p, signum)
* be awakened.
*/
if ((prop & SA_CONT) && action == SIG_DFL) {
- p->p_siglist &= ~mask;
+ SIGDELSET(p->p_siglist, sig);
goto out;
}
/*
@@ -882,8 +1091,8 @@ psignal(p, signum)
*/
if (p->p_flag & P_PPWAIT)
goto out;
- p->p_siglist &= ~mask;
- p->p_xstat = signum;
+ SIGDELSET(p->p_siglist, sig);
+ p->p_xstat = sig;
if ((p->p_pptr->p_procsig->ps_flag & P_NOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
stop(p);
@@ -903,7 +1112,7 @@ psignal(p, signum)
/*
* Kill signal always sets processes running.
*/
- if (signum == SIGKILL)
+ if (sig == SIGKILL)
goto runfast;
if (prop & SA_CONT) {
@@ -918,7 +1127,7 @@ psignal(p, signum)
* Otherwise, process goes back to sleep state.
*/
if (action == SIG_DFL)
- p->p_siglist &= ~mask;
+ SIGDELSET(p->p_siglist, sig);
if (action == SIG_CATCH)
goto runfast;
if (p->p_wchan == 0)
@@ -932,7 +1141,7 @@ psignal(p, signum)
* Already stopped, don't need to stop again.
* (If we did the shell could get confused.)
*/
- p->p_siglist &= ~mask; /* take it away */
+ SIGDELSET(p->p_siglist, sig);
goto out;
}
@@ -983,35 +1192,36 @@ out:
* by checking the pending signal masks in the CURSIG macro.) The normal call
* sequence is
*
- * while (signum = CURSIG(curproc))
- * postsig(signum);
+ * while (sig = CURSIG(curproc))
+ * postsig(sig);
*/
int
issignal(p)
register struct proc *p;
{
- register int signum, mask, prop;
+ sigset_t mask;
+ register int sig, prop;
for (;;) {
int traced = (p->p_flag & P_TRACED) || (p->p_stops & S_SIG);
- mask = p->p_siglist & ~p->p_sigmask;
+ mask = p->p_siglist;
+ SIGSETNAND(mask, p->p_sigmask);
if (p->p_flag & P_PPWAIT)
- mask &= ~stopsigmask;
- if (mask == 0) /* no signal to send */
+ SIG_STOPSIGMASK(mask);
+ if (!SIGNOTEMPTY(mask)) /* no signal to send */
return (0);
- signum = ffs((long)mask);
- mask = sigmask(signum);
- prop = sigprop[signum];
+ sig = sig_ffs(&mask);
+ prop = sigprop(sig);
- STOPEVENT(p, S_SIG, signum);
+ STOPEVENT(p, S_SIG, sig);
/*
* We should see pending but ignored signals
* only if P_TRACED was on when they were posted.
*/
- if ((mask & p->p_sigignore) && (traced == 0)) {
- p->p_siglist &= ~mask;
+ if (SIGISMEMBER(p->p_sigignore, sig) && (traced == 0)) {
+ SIGDELSET(p->p_siglist, sig);
continue;
}
if (p->p_flag & P_TRACED && (p->p_flag & P_PPWAIT) == 0) {
@@ -1019,7 +1229,7 @@ issignal(p)
* If traced, always stop, and stay
* stopped until released by the parent.
*/
- p->p_xstat = signum;
+ p->p_xstat = sig;
psignal(p->p_pptr, SIGCHLD);
do {
stop(p);
@@ -1040,18 +1250,17 @@ issignal(p)
* then it will leave it in p->p_xstat;
* otherwise we just look for signals again.
*/
- p->p_siglist &= ~mask; /* clear the old signal */
- signum = p->p_xstat;
- if (signum == 0)
+ SIGDELSET(p->p_siglist, sig); /* clear old signal */
+ sig = p->p_xstat;
+ if (sig == 0)
continue;
/*
* Put the new signal into p_siglist. If the
* signal is being masked, look for other signals.
*/
- mask = sigmask(signum);
- p->p_siglist |= mask;
- if (p->p_sigmask & mask)
+ SIGADDSET(p->p_siglist, sig);
+ if (SIGISMEMBER(p->p_sigmask, sig))
continue;
}
@@ -1060,7 +1269,7 @@ issignal(p)
* Return the signal's number, or fall through
* to clear it from the pending mask.
*/
- switch ((int)(intptr_t)p->p_sigacts->ps_sigact[signum]) {
+ switch ((int)(intptr_t)p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) {
case (int)SIG_DFL:
/*
@@ -1073,7 +1282,7 @@ issignal(p)
* in init? XXX
*/
printf("Process (pid %lu) got signal %d\n",
- (u_long)p->p_pid, signum);
+ (u_long)p->p_pid, sig);
#endif
break; /* == ignore */
}
@@ -1089,7 +1298,7 @@ issignal(p)
(p->p_pgrp->pg_jobc == 0 &&
prop & SA_TTYSTOP))
break; /* == ignore */
- p->p_xstat = signum;
+ p->p_xstat = sig;
stop(p);
if ((p->p_pptr->p_procsig->ps_flag & P_NOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
@@ -1102,7 +1311,7 @@ issignal(p)
*/
break; /* == ignore */
} else
- return (signum);
+ return (sig);
/*NOTREACHED*/
case (int)SIG_IGN:
@@ -1121,9 +1330,9 @@ issignal(p)
* This signal has an action, let
* postsig() process it.
*/
- return (signum);
+ return (sig);
}
- p->p_siglist &= ~mask; /* take the signal! */
+ SIGDELSET(p->p_siglist, sig); /* take the signal! */
}
/* NOTREACHED */
}
@@ -1148,39 +1357,39 @@ stop(p)
* from the current set of pending signals.
*/
void
-postsig(signum)
- register int signum;
+postsig(sig)
+ register int sig;
{
register struct proc *p = curproc;
- register struct sigacts *ps = p->p_sigacts;
- register sig_t action;
- int code, mask, returnmask;
+ struct sigacts *ps = p->p_sigacts;
+ sig_t action;
+ sigset_t returnmask;
+ int code;
- KASSERT(signum != 0, ("postsig"));
+ KASSERT(sig != 0, ("postsig"));
- mask = sigmask(signum);
- p->p_siglist &= ~mask;
- action = ps->ps_sigact[signum];
+ SIGDELSET(p->p_siglist, sig);
+ action = ps->ps_sigact[_SIG_IDX(sig)];
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
ktrpsig(p->p_tracep,
- signum, action, p->p_oldsigmask ?
- p->p_oldsigmask : p->p_sigmask, 0);
+ sig, action, SIGNOTEMPTY(p->p_oldsigmask) ?
+ &p->p_oldsigmask : &p->p_sigmask, 0);
#endif
- STOPEVENT(p, S_SIG, signum);
+ STOPEVENT(p, S_SIG, sig);
if (action == SIG_DFL) {
/*
* Default action, where the default is to kill
* the process. (Other cases were ignored above.)
*/
- sigexit(p, signum);
+ sigexit(p, sig);
/* NOTREACHED */
} else {
/*
* If we get here, the signal must be caught.
*/
- KASSERT(action != SIG_IGN && (p->p_sigmask & mask) == 0,
+ KASSERT(action != SIG_IGN && !SIGISMEMBER(p->p_sigmask, sig),
("postsig action"));
/*
* Set the new mask value and also defer further
@@ -1192,32 +1401,36 @@ postsig(signum)
* restored after the signal processing is completed.
*/
(void) splhigh();
- if (p->p_oldsigmask) {
+ if (SIGNOTEMPTY(p->p_oldsigmask)) {
returnmask = p->p_oldsigmask;
- p->p_oldsigmask = 0;
+ SIGEMPTYSET(p->p_oldsigmask);
} else
returnmask = p->p_sigmask;
- p->p_sigmask |= ps->ps_catchmask[signum] |
- (mask & ~ps->ps_signodefer);
- if ((ps->ps_sigreset & mask) != 0) {
+
+ SIGSETOR(p->p_sigmask, ps->ps_catchmask[_SIG_IDX(sig)]);
+ if (!SIGISMEMBER(ps->ps_signodefer, sig))
+ SIGADDSET(p->p_sigmask, sig);
+
+ if (SIGISMEMBER(ps->ps_sigreset, sig)) {
/*
- * See setsigvec() for origin of this code.
+ * See do_sigaction() for origin of this code.
*/
- p->p_sigcatch &= ~mask;
- if (signum != SIGCONT && sigprop[signum] & SA_IGNORE)
- p->p_sigignore |= mask;
- ps->ps_sigact[signum] = SIG_DFL;
+ SIGDELSET(p->p_sigcatch, sig);
+ if (sig != SIGCONT &&
+ sigprop(sig) & SA_IGNORE)
+ SIGADDSET(p->p_sigignore, sig);
+ ps->ps_sigact[_SIG_IDX(sig)] = SIG_DFL;
}
(void) spl0();
p->p_stats->p_ru.ru_nsignals++;
- if (p->p_sig != signum) {
+ if (p->p_sig != sig) {
code = 0;
} else {
code = p->p_code;
p->p_code = 0;
p->p_sig = 0;
}
- (*p->p_sysent->sv_sendsig)(action, signum, returnmask, code);
+ (*p->p_sysent->sv_sendsig)(action, sig, &returnmask, code);
}
}
@@ -1243,14 +1456,14 @@ killproc(p, why)
* does not return.
*/
void
-sigexit(p, signum)
+sigexit(p, sig)
register struct proc *p;
- int signum;
+ int sig;
{
p->p_acflag |= AXSIG;
- if (sigprop[signum] & SA_CORE) {
- p->p_sig = signum;
+ if (sigprop(sig) & SA_CORE) {
+ p->p_sig = sig;
/*
* Log signals which would cause core dumps
* (Log as LOG_INFO to appease those who don't want
@@ -1258,16 +1471,16 @@ sigexit(p, signum)
* XXX : Todo, as well as euid, write out ruid too
*/
if (coredump(p) == 0)
- signum |= WCOREFLAG;
+ sig |= WCOREFLAG;
if (kern_logsigexit)
log(LOG_INFO,
"pid %d (%s), uid %d: exited on signal %d%s\n",
p->p_pid, p->p_comm,
p->p_cred && p->p_ucred ? p->p_ucred->cr_uid : -1,
- signum &~ WCOREFLAG,
- signum & WCOREFLAG ? " (core dumped)" : "");
+ sig &~ WCOREFLAG,
+ sig & WCOREFLAG ? " (core dumped)" : "");
}
- exit1(p, W_EXITCODE(0, signum));
+ exit1(p, W_EXITCODE(0, sig));
/* NOTREACHED */
}
@@ -1443,9 +1656,9 @@ nosys(p, args)
* stored credentials rather than those of the current process.
*/
void
-pgsigio(sigio, signum, checkctty)
+pgsigio(sigio, sig, checkctty)
struct sigio *sigio;
- int signum, checkctty;
+ int sig, checkctty;
{
if (sigio == NULL)
return;
@@ -1453,7 +1666,7 @@ pgsigio(sigio, signum, checkctty)
if (sigio->sio_pgid > 0) {
if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred,
sigio->sio_proc))
- psignal(sigio->sio_proc, signum);
+ psignal(sigio->sio_proc, sig);
} else if (sigio->sio_pgid < 0) {
struct proc *p;
@@ -1461,6 +1674,6 @@ pgsigio(sigio, signum, checkctty)
p = p->p_pglist.le_next)
if (CANSIGIO(sigio->sio_ruid, sigio->sio_ucred, p) &&
(checkctty == 0 || (p->p_flag & P_CONTROLT)))
- psignal(p, signum);
+ psignal(p, sig);
}
}
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index be058da..293a75f 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -459,7 +459,7 @@ resume:
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 0, 0);
#endif
- if (p->p_sigacts->ps_sigintr & sigmask(sig))
+ if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig))
return (EINTR);
return (ERESTART);
}
@@ -599,7 +599,7 @@ resume:
if (KTRPOINT(p, KTR_CSW))
ktrcsw(p->p_tracep, 0, 0);
#endif
- if (p->p_sigacts->ps_sigintr & sigmask(sig))
+ if (SIGISMEMBER(p->p_sigacts->ps_sigintr, sig))
return (EINTR);
return (ERESTART);
}
diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c
index 657b0e3..43fce45 100644
--- a/sys/kern/syscalls.c
+++ b/sys/kern/syscalls.c
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.64 1999/09/11 00:45:58 alfred Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.65 1999/09/29 15:01:21 marcel Exp
*/
char *syscallnames[] = {
@@ -53,13 +53,13 @@ char *syscallnames[] = {
"getegid", /* 43 = getegid */
"profil", /* 44 = profil */
"ktrace", /* 45 = ktrace */
- "sigaction", /* 46 = sigaction */
+ "osigaction", /* 46 = osigaction */
"getgid", /* 47 = getgid */
- "sigprocmask", /* 48 = sigprocmask */
+ "osigprocmask", /* 48 = osigprocmask */
"getlogin", /* 49 = getlogin */
"setlogin", /* 50 = setlogin */
"acct", /* 51 = acct */
- "sigpending", /* 52 = sigpending */
+ "osigpending", /* 52 = osigpending */
"sigaltstack", /* 53 = sigaltstack */
"ioctl", /* 54 = ioctl */
"reboot", /* 55 = reboot */
@@ -110,7 +110,7 @@ char *syscallnames[] = {
"getpriority", /* 100 = getpriority */
"old.send", /* 101 = old send */
"old.recv", /* 102 = old recv */
- "sigreturn", /* 103 = sigreturn */
+ "osigreturn", /* 103 = osigreturn */
"bind", /* 104 = bind */
"setsockopt", /* 105 = setsockopt */
"listen", /* 106 = listen */
@@ -118,7 +118,7 @@ char *syscallnames[] = {
"old.sigvec", /* 108 = old sigvec */
"old.sigblock", /* 109 = old sigblock */
"old.sigsetmask", /* 110 = old sigsetmask */
- "sigsuspend", /* 111 = sigsuspend */
+ "osigsuspend", /* 111 = osigsuspend */
"old.sigstack", /* 112 = old sigstack */
"old.recvmsg", /* 113 = old recvmsg */
"old.sendmsg", /* 114 = old sendmsg */
@@ -347,4 +347,11 @@ char *syscallnames[] = {
"kldsym", /* 337 = kldsym */
"jail", /* 338 = jail */
"#339", /* 339 = pioctl */
+ "sigprocmask", /* 340 = sigprocmask */
+ "sigsuspend", /* 341 = sigsuspend */
+ "sigaction", /* 342 = sigaction */
+ "sigpending", /* 343 = sigpending */
+ "sigreturn", /* 344 = sigreturn */
+ "#345", /* 345 = sigtimedwait */
+ "#346", /* 346 = sigwaitinfo */
};
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index f311f76..7f4cd43 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -739,10 +739,9 @@ ttioctl(tp, cmd, data, flag)
case TIOCSETP:
case TIOCSLTC:
#endif
- while (isbackground(p, tp) &&
- (p->p_flag & P_PPWAIT) == 0 &&
- (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
- (p->p_sigmask & sigmask(SIGTTOU)) == 0) {
+ while (isbackground(p, tp) && !(p->p_flag & P_PPWAIT) &&
+ !SIGISMEMBER(p->p_sigignore, SIGTTOU) &&
+ !SIGISMEMBER(p->p_sigmask, SIGTTOU)) {
if (p->p_pgrp->pg_jobc == 0)
return (EIO);
pgsignal(p->p_pgrp, SIGTTOU, 1);
@@ -1448,9 +1447,9 @@ loop:
*/
if (isbackground(p, tp)) {
splx(s);
- if ((p->p_sigignore & sigmask(SIGTTIN)) ||
- (p->p_sigmask & sigmask(SIGTTIN)) ||
- p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
+ if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
+ SIGISMEMBER(p->p_sigmask, SIGTTIN) ||
+ (p->p_flag & P_PPWAIT) || p->p_pgrp->pg_jobc == 0)
return (EIO);
pgsignal(p->p_pgrp, SIGTTIN, 1);
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ttybg2", 0);
@@ -1699,17 +1698,20 @@ ttycheckoutq(tp, wait)
register struct tty *tp;
int wait;
{
- int hiwat, s, oldsig;
+ int hiwat, s;
+ sigset_t oldmask;
hiwat = tp->t_ohiwat;
+ SIGEMPTYSET(oldmask);
s = spltty();
- oldsig = wait ? curproc->p_siglist : 0;
+ if (wait)
+ oldmask = curproc->p_siglist;
if (tp->t_outq.c_cc > hiwat + OBUFSIZ + 100)
while (tp->t_outq.c_cc > hiwat) {
ttstart(tp);
if (tp->t_outq.c_cc <= hiwat)
break;
- if (wait == 0 || curproc->p_siglist != oldsig) {
+ if (!(wait && SIGSETEQ(curproc->p_siglist, oldmask))) {
splx(s);
return (0);
}
@@ -1766,9 +1768,9 @@ loop:
*/
p = curproc;
if (isbackground(p, tp) &&
- ISSET(tp->t_lflag, TOSTOP) && (p->p_flag & P_PPWAIT) == 0 &&
- (p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
- (p->p_sigmask & sigmask(SIGTTOU)) == 0) {
+ ISSET(tp->t_lflag, TOSTOP) && !(p->p_flag & P_PPWAIT) &&
+ !SIGISMEMBER(p->p_sigignore, SIGTTOU) &&
+ !SIGISMEMBER(p->p_sigmask, SIGTTOU)) {
if (p->p_pgrp->pg_jobc == 0) {
error = EIO;
goto out;
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 238fdad..539ee0b 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -243,10 +243,9 @@ ptsread(dev, uio, flag)
again:
if (pti->pt_flags & PF_REMOTE) {
while (isbackground(p, tp)) {
- if ((p->p_sigignore & sigmask(SIGTTIN)) ||
- (p->p_sigmask & sigmask(SIGTTIN)) ||
- p->p_pgrp->pg_jobc == 0 ||
- p->p_flag & P_PPWAIT)
+ if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
+ SIGISMEMBER(p->p_sigmask, SIGTTIN) ||
+ p->p_pgrp->pg_jobc == 0 || p->p_flag & P_PPWAIT)
return (EIO);
pgsignal(p->p_pgrp, SIGTTIN, 1);
error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, "ptsbg",
diff --git a/sys/miscfs/procfs/procfs_ctl.c b/sys/miscfs/procfs/procfs_ctl.c
index 4f4d84b..9a74aa3 100644
--- a/sys/miscfs/procfs/procfs_ctl.c
+++ b/sys/miscfs/procfs/procfs_ctl.c
@@ -192,7 +192,7 @@ procfs_control(curp, p, op)
p->p_flag &= ~P_TRACED;
/* remove pending SIGTRAP, else the process will die */
- p->p_siglist &= ~sigmask (SIGTRAP);
+ SIGDELSET(p->p_siglist, SIGTRAP);
/* give process back to original parent */
if (p->p_oppid != p->p_pptr->p_pid) {
diff --git a/sys/nfs/nfs.h b/sys/nfs/nfs.h
index efdb607..296e34f 100644
--- a/sys/nfs/nfs.h
+++ b/sys/nfs/nfs.h
@@ -326,8 +326,10 @@ struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
-#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
- sigmask(SIGHUP)|sigmask(SIGQUIT))
+#define NFSINT_SIGMASK(set) \
+ (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
+ SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
+ SIGISMEMBER(set, SIGQUIT))
/*
* Socket errors ignored for connectionless sockets??
diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c
index 0059c51..9434fb9 100644
--- a/sys/nfs/nfs_socket.c
+++ b/sys/nfs/nfs_socket.c
@@ -55,6 +55,7 @@
#include <sys/syslog.h>
#include <sys/tprintf.h>
#include <sys/sysctl.h>
+#include <sys/signalvar.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -1501,14 +1502,16 @@ nfs_sigintr(nmp, rep, p)
struct nfsreq *rep;
register struct proc *p;
{
+ sigset_t tmpset;
+ tmpset = p->p_siglist;
+ SIGSETNAND(tmpset, p->p_sigmask);
+ SIGSETNAND(tmpset, p->p_sigignore);
if (rep && (rep->r_flags & R_SOFTTERM))
return (EINTR);
if (!(nmp->nm_flag & NFSMNT_INT))
return (0);
- if (p && p->p_siglist &&
- (((p->p_siglist & ~p->p_sigmask) & ~p->p_sigignore) &
- NFSINT_SIGMASK))
+ if (p && SIGNOTEMPTY(p->p_siglist) && NFSINT_SIGMASK(tmpset))
return (EINTR);
return (0);
}
diff --git a/sys/nfsclient/nfs.h b/sys/nfsclient/nfs.h
index efdb607..296e34f 100644
--- a/sys/nfsclient/nfs.h
+++ b/sys/nfsclient/nfs.h
@@ -326,8 +326,10 @@ struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
-#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
- sigmask(SIGHUP)|sigmask(SIGQUIT))
+#define NFSINT_SIGMASK(set) \
+ (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
+ SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
+ SIGISMEMBER(set, SIGQUIT))
/*
* Socket errors ignored for connectionless sockets??
diff --git a/sys/nfsclient/nfs_socket.c b/sys/nfsclient/nfs_socket.c
index 0059c51..9434fb9 100644
--- a/sys/nfsclient/nfs_socket.c
+++ b/sys/nfsclient/nfs_socket.c
@@ -55,6 +55,7 @@
#include <sys/syslog.h>
#include <sys/tprintf.h>
#include <sys/sysctl.h>
+#include <sys/signalvar.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -1501,14 +1502,16 @@ nfs_sigintr(nmp, rep, p)
struct nfsreq *rep;
register struct proc *p;
{
+ sigset_t tmpset;
+ tmpset = p->p_siglist;
+ SIGSETNAND(tmpset, p->p_sigmask);
+ SIGSETNAND(tmpset, p->p_sigignore);
if (rep && (rep->r_flags & R_SOFTTERM))
return (EINTR);
if (!(nmp->nm_flag & NFSMNT_INT))
return (0);
- if (p && p->p_siglist &&
- (((p->p_siglist & ~p->p_sigmask) & ~p->p_sigignore) &
- NFSINT_SIGMASK))
+ if (p && SIGNOTEMPTY(p->p_siglist) && NFSINT_SIGMASK(tmpset))
return (EINTR);
return (0);
}
diff --git a/sys/nfsclient/nfsargs.h b/sys/nfsclient/nfsargs.h
index efdb607..296e34f 100644
--- a/sys/nfsclient/nfsargs.h
+++ b/sys/nfsclient/nfsargs.h
@@ -326,8 +326,10 @@ struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
-#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
- sigmask(SIGHUP)|sigmask(SIGQUIT))
+#define NFSINT_SIGMASK(set) \
+ (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
+ SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
+ SIGISMEMBER(set, SIGQUIT))
/*
* Socket errors ignored for connectionless sockets??
diff --git a/sys/nfsclient/nfsstats.h b/sys/nfsclient/nfsstats.h
index efdb607..296e34f 100644
--- a/sys/nfsclient/nfsstats.h
+++ b/sys/nfsclient/nfsstats.h
@@ -326,8 +326,10 @@ struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
-#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
- sigmask(SIGHUP)|sigmask(SIGQUIT))
+#define NFSINT_SIGMASK(set) \
+ (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
+ SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
+ SIGISMEMBER(set, SIGQUIT))
/*
* Socket errors ignored for connectionless sockets??
diff --git a/sys/nfsserver/nfs.h b/sys/nfsserver/nfs.h
index efdb607..296e34f 100644
--- a/sys/nfsserver/nfs.h
+++ b/sys/nfsserver/nfs.h
@@ -326,8 +326,10 @@ struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
-#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
- sigmask(SIGHUP)|sigmask(SIGQUIT))
+#define NFSINT_SIGMASK(set) \
+ (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
+ SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
+ SIGISMEMBER(set, SIGQUIT))
/*
* Socket errors ignored for connectionless sockets??
diff --git a/sys/nfsserver/nfs_srvsock.c b/sys/nfsserver/nfs_srvsock.c
index 0059c51..9434fb9 100644
--- a/sys/nfsserver/nfs_srvsock.c
+++ b/sys/nfsserver/nfs_srvsock.c
@@ -55,6 +55,7 @@
#include <sys/syslog.h>
#include <sys/tprintf.h>
#include <sys/sysctl.h>
+#include <sys/signalvar.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
@@ -1501,14 +1502,16 @@ nfs_sigintr(nmp, rep, p)
struct nfsreq *rep;
register struct proc *p;
{
+ sigset_t tmpset;
+ tmpset = p->p_siglist;
+ SIGSETNAND(tmpset, p->p_sigmask);
+ SIGSETNAND(tmpset, p->p_sigignore);
if (rep && (rep->r_flags & R_SOFTTERM))
return (EINTR);
if (!(nmp->nm_flag & NFSMNT_INT))
return (0);
- if (p && p->p_siglist &&
- (((p->p_siglist & ~p->p_sigmask) & ~p->p_sigignore) &
- NFSINT_SIGMASK))
+ if (p && SIGNOTEMPTY(p->p_siglist) && NFSINT_SIGMASK(tmpset))
return (EINTR);
return (0);
}
diff --git a/sys/nfsserver/nfsrvstats.h b/sys/nfsserver/nfsrvstats.h
index efdb607..296e34f 100644
--- a/sys/nfsserver/nfsrvstats.h
+++ b/sys/nfsserver/nfsrvstats.h
@@ -326,8 +326,10 @@ struct uio; struct buf; struct vattr; struct nameidata; /* XXX */
* such as SIGALRM will not expect file I/O system calls to be interrupted
* by them and break.
*/
-#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
- sigmask(SIGHUP)|sigmask(SIGQUIT))
+#define NFSINT_SIGMASK(set) \
+ (SIGISMEMBER(set, SIGINT) || SIGISMEMBER(set, SIGTERM) || \
+ SIGISMEMBER(set, SIGHUP) || SIGISMEMBER(set, SIGKILL) || \
+ SIGISMEMBER(set, SIGQUIT))
/*
* Socket errors ignored for connectionless sockets??
diff --git a/sys/sys/_sigset.h b/sys/sys/_sigset.h
index 4a0fee8..8d1e773 100644
--- a/sys/sys/_sigset.h
+++ b/sys/sys/_sigset.h
@@ -44,56 +44,65 @@
#include <sys/cdefs.h>
#include <sys/_posix.h>
+#include <sys/types.h>
#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
-#endif
+/*
+ * sigset_t macros
+ */
+#define _SIG_WORDS 4
+#define _SIG_MAXSIG 128
+#define _SIG_IDX(sig) ((sig) - 1)
+#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
+#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
-#define SIGHUP 1 /* hangup */
-#define SIGINT 2 /* interrupt */
-#define SIGQUIT 3 /* quit */
-#define SIGILL 4 /* illegal instruction (not reset when caught) */
+/*
+ * system defined signals
+ */
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instr. (not reset when caught) */
#ifndef _POSIX_SOURCE
-#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
#endif
-#define SIGABRT 6 /* abort() */
+#define SIGABRT 6 /* abort() */
#ifndef _POSIX_SOURCE
-#define SIGIOT SIGABRT /* compatibility */
-#define SIGEMT 7 /* EMT instruction */
+#define SIGIOT SIGABRT /* compatibility */
+#define SIGEMT 7 /* EMT instruction */
#endif
-#define SIGFPE 8 /* floating point exception */
-#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGFPE 8 /* floating point exception */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
#ifndef _POSIX_SOURCE
-#define SIGBUS 10 /* bus error */
+#define SIGBUS 10 /* bus error */
#endif
-#define SIGSEGV 11 /* segmentation violation */
+#define SIGSEGV 11 /* segmentation violation */
#ifndef _POSIX_SOURCE
-#define SIGSYS 12 /* non-existent system call invoked */
+#define SIGSYS 12 /* non-existent system call invoked */
#endif
-#define SIGPIPE 13 /* write on a pipe with no one to read it */
-#define SIGALRM 14 /* alarm clock */
-#define SIGTERM 15 /* software termination signal from kill */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
#ifndef _POSIX_SOURCE
-#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGURG 16 /* urgent condition on IO channel */
#endif
-#define SIGSTOP 17 /* sendable stop signal not from tty */
-#define SIGTSTP 18 /* stop signal from tty */
-#define SIGCONT 19 /* continue a stopped process */
-#define SIGCHLD 20 /* to parent on child stop or exit */
-#define SIGTTIN 21 /* to readers pgrp upon background tty read */
-#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN if (tp->t_local&LTOSTOP) */
#ifndef _POSIX_SOURCE
-#define SIGIO 23 /* input/output possible signal */
-#define SIGXCPU 24 /* exceeded CPU time limit */
-#define SIGXFSZ 25 /* exceeded file size limit */
-#define SIGVTALRM 26 /* virtual time alarm */
-#define SIGPROF 27 /* profiling time alarm */
-#define SIGWINCH 28 /* window size changes */
-#define SIGINFO 29 /* information request */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window size changes */
+#define SIGINFO 29 /* information request */
#endif
-#define SIGUSR1 30 /* user defined signal 1 */
-#define SIGUSR2 31 /* user defined signal 2 */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
/*-
* Type of a signal handling function.
@@ -113,56 +122,41 @@
*/
typedef void __sighandler_t __P((int));
-#if defined(_P1003_1B_VISIBLE_HISTORICALLY) || \
- (!defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE))
+#define SIG_DFL ((__sighandler_t *)0)
+#define SIG_IGN ((__sighandler_t *)1)
+#define SIG_HOLD ((__sighandler_t *)2)
+#define SIG_ERR ((__sighandler_t *)-1)
+
union sigval {
/* Members as suggested by Annex C of POSIX 1003.1b. */
- int sigval_int;
- void *sigval_ptr;
+ int sigval_int;
+ void *sigval_ptr;
};
-#endif /* !_ANSI_SOURCE && _P1003_1B_VISIBLE_HISTORICALLY */
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-/* POSIX 1003.1b required values. */
-#define SI_USER 0x10001
-#define SI_QUEUE 0x10002
-#define SI_TIMER 0x10003
-#define SI_ASYNCIO 0x10004
-#define SI_MESGQ 0x10005
-
-/* Additional FreeBSD values. */
-#define SI_UNDEFINED 0
-
-struct __siginfo {
- struct sigcontext si_sc;
- int si_signo; /* signal number */
+typedef struct {
+ int si_signo; /* signal number */
+ int si_errno; /* errno association */
/*
* Cause of signal, one of the SI_ macros or signal-specific
* values, i.e. one of the FPE_... values for SIGFPE. This
* value is equivalent to the second argument to an old-style
* FreeBSD signal handler.
*/
- int si_code;
-
- union sigval si_value;
-};
-#else /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
-struct __siginfo;
-#endif /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
-
-typedef struct __siginfo siginfo_t;
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-typedef void __siginfohandler_t __P((int, siginfo_t *, void *));
-#endif /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
-
-#define SIG_DFL ((__sighandler_t *)0)
-#define SIG_IGN ((__sighandler_t *)1)
-#define SIG_ERR ((__sighandler_t *)-1)
-
-#ifndef _ANSI_SOURCE
-typedef unsigned int sigset_t;
+ int si_code; /* signal code */
+ pid_t si_pid; /* sending process */
+ uid_t si_uid; /* sender's ruid */
+ int si_status; /* exit value */
+ void *si_addr; /* faulting instruction */
+ union sigval si_value; /* signal value */
+ long si_band; /* band event for SIGPOLL */
+ int __spare__[7]; /* gimme some slack */
+} siginfo_t;
+
+typedef struct {
+ unsigned int __bits[_SIG_WORDS];
+} sigset_t;
+
+#if !defined(_ANSI_SOURCE)
/*
* Signal vector "template" used in sigaction call.
@@ -172,16 +166,19 @@ struct sigaction {
void (*__sa_handler) __P((int));
void (*__sa_sigaction) __P((int, siginfo_t *, void *));
} __sigaction_u; /* signal handler */
- sigset_t sa_mask; /* signal mask to apply */
- int sa_flags; /* see signal options below */
+ int sa_flags; /* see signal options below */
+ sigset_t sa_mask; /* signal mask to apply */
};
+
/* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */
#define sa_handler __sigaction_u.__sa_handler
-#ifndef _POSIX_SOURCE
+
+#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
+
+#if !defined(_POSIX_SOURCE)
+
#define sa_sigaction __sigaction_u.__sa_sigaction
-#endif
-#ifndef _POSIX_SOURCE
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
#define SA_RESTART 0x0002 /* restart system call on signal return */
#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
@@ -191,17 +188,21 @@ struct sigaction {
#ifdef COMPAT_SUNOS
#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
#endif
-#endif /* _POSIX_SOURCE */
-#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
-/*
- * Flags for sigprocmask:
- */
-#define SIG_BLOCK 1 /* block specified signal set */
-#define SIG_UNBLOCK 2 /* unblock specified signal set */
-#define SIG_SETMASK 3 /* set specified signal set */
+#define NSIG 32
+
+/* POSIX 1003.1b required values. */
+#define SI_USER 0x10001
+#define SI_QUEUE 0x10002
+#define SI_TIMER 0x10003
+#define SI_ASYNCIO 0x10004
+#define SI_MESGQ 0x10005
+
+/* Additional FreeBSD values. */
+#define SI_UNDEFINED 0
+
+typedef void __siginfohandler_t __P((int, siginfo_t *, void *));
-#ifndef _POSIX_SOURCE
typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
#ifdef _BSD_SIZE_T_
@@ -210,26 +211,32 @@ typedef _BSD_SIZE_T_ size_t;
#endif
/*
- * Structure used in sigaltstack call.
+ * sigaltstack
*/
-struct sigaltstack {
- char *ss_sp; /* signal stack base */
- size_t ss_size; /* signal stack length */
- int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
-};
+typedef struct sigaltstack {
+ char *ss_sp; /* signal stack base */
+ unsigned int ss_size; /* signal stack length */
+ int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
+} stack_t;
+
#define SS_ONSTACK 0x0001 /* take signal on alternate stack */
#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
#define MINSIGSTKSZ 8192 /* minimum allowable stack */
#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
/*
+ * Suck in definition of ucontext_t
+ */
+#include <sys/ucontext.h>
+
+/*
* 4.3 compatibility:
* Signal vector "template" used in sigvec call.
*/
struct sigvec {
- __sighandler_t *sv_handler; /* signal handler */
- int sv_mask; /* signal mask to apply */
- int sv_flags; /* see signal options below */
+ __sighandler_t *sv_handler; /* signal handler */
+ int sv_mask; /* signal mask to apply */
+ int sv_flags; /* see signal options below */
};
#define SV_ONSTACK SA_ONSTACK
@@ -244,8 +251,8 @@ struct sigvec {
* Structure used in sigstack call.
*/
struct sigstack {
- char *ss_sp; /* signal stack pointer */
- int ss_onstack; /* current status */
+ char *ss_sp; /* signal stack pointer */
+ int ss_onstack; /* current status */
};
/*
@@ -256,21 +263,25 @@ struct sigstack {
#define BADSIG SIG_ERR
-#endif /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
+#endif /* !_POSIX_SOURCE */
-#if !defined(_ANSI_SOURCE) && defined(_P1003_1B_VISIBLE_HISTORICALLY)
+/*
+ * Flags for sigprocmask:
+ */
+#define SIG_BLOCK 1 /* block specified signal set */
+#define SIG_UNBLOCK 2 /* unblock specified signal set */
+#define SIG_SETMASK 3 /* set specified signal set */
struct sigevent {
- int sigev_notify; /* Notification type */
- int sigev_signo; /* Signal number */
- union sigval sigev_value; /* Signal value */
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union sigval sigev_value; /* Signal value */
};
#define SIGEV_NONE 0 /* No async notification */
#define SIGEV_SIGNAL 1 /* Generate a queued signal */
-#endif /* ! _ANSI_SOURCE && _P1003_1B_VISIBLE_HISTORICALLY */
+#endif /* !_ANSI_SOURCE */
/*
* For historical reasons; programs expect signal's return value to be
diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h
index df818da..dc3e120 100644
--- a/sys/sys/ktrace.h
+++ b/sys/sys/ktrace.h
@@ -120,8 +120,8 @@ struct ktr_genio {
struct ktr_psig {
int signo;
sig_t action;
- int mask;
int code;
+ sigset_t mask;
};
/*
@@ -159,7 +159,7 @@ struct ktr_csw {
#ifdef KERNEL
void ktrnamei __P((struct vnode *,char *));
void ktrcsw __P((struct vnode *,int,int));
-void ktrpsig __P((struct vnode *, int, sig_t, int, int));
+void ktrpsig __P((struct vnode *, int, sig_t, sigset_t *, int));
void ktrgenio __P((struct vnode *,int, enum uio_rw,struct iovec *,int,int));
void ktrsyscall __P((struct vnode *, int, int narg, register_t args[]));
void ktrsysret __P((struct vnode *, int, int, register_t));
diff --git a/sys/sys/param.h b/sys/sys/param.h
index 3ae239c..9729433 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -46,7 +46,7 @@
#define BSD4_3 1
#define BSD4_4 1
#undef __FreeBSD_version
-#define __FreeBSD_version 400010 /* Master, propagated to newvers */
+#define __FreeBSD_version 400011 /* Master, propagated to newvers */
#ifndef NULL
#define NULL 0
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 7885af3..99e429f 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -167,7 +167,7 @@ struct proc {
int p_traceflag; /* Kernel trace points. */
struct vnode *p_tracep; /* Trace to vnode. */
- int p_siglist; /* Signals arrived but not delivered. */
+ sigset_t p_siglist; /* Signals arrived but not delivered. */
struct vnode *p_textvp; /* Vnode of executable. */
@@ -271,6 +271,7 @@ struct proc {
#define P_DEADLKTREAT 0x800000 /* lock aquisition - deadlock treatment */
#define P_JAILED 0x1000000 /* Process is in jail */
+#define P_NEWSIGSET 0x2000000 /* Process uses new sigset_t */
/*
* MOVE TO ucred.h?
diff --git a/sys/sys/signal.h b/sys/sys/signal.h
index 4a0fee8..8d1e773 100644
--- a/sys/sys/signal.h
+++ b/sys/sys/signal.h
@@ -44,56 +44,65 @@
#include <sys/cdefs.h>
#include <sys/_posix.h>
+#include <sys/types.h>
#include <machine/signal.h> /* sig_atomic_t; trap codes; sigcontext */
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-#define NSIG 32 /* counting 0; could be 33 (mask is 1-32) */
-#endif
+/*
+ * sigset_t macros
+ */
+#define _SIG_WORDS 4
+#define _SIG_MAXSIG 128
+#define _SIG_IDX(sig) ((sig) - 1)
+#define _SIG_WORD(sig) (_SIG_IDX(sig) >> 5)
+#define _SIG_BIT(sig) (1 << (_SIG_IDX(sig) & 31))
-#define SIGHUP 1 /* hangup */
-#define SIGINT 2 /* interrupt */
-#define SIGQUIT 3 /* quit */
-#define SIGILL 4 /* illegal instruction (not reset when caught) */
+/*
+ * system defined signals
+ */
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instr. (not reset when caught) */
#ifndef _POSIX_SOURCE
-#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
#endif
-#define SIGABRT 6 /* abort() */
+#define SIGABRT 6 /* abort() */
#ifndef _POSIX_SOURCE
-#define SIGIOT SIGABRT /* compatibility */
-#define SIGEMT 7 /* EMT instruction */
+#define SIGIOT SIGABRT /* compatibility */
+#define SIGEMT 7 /* EMT instruction */
#endif
-#define SIGFPE 8 /* floating point exception */
-#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGFPE 8 /* floating point exception */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
#ifndef _POSIX_SOURCE
-#define SIGBUS 10 /* bus error */
+#define SIGBUS 10 /* bus error */
#endif
-#define SIGSEGV 11 /* segmentation violation */
+#define SIGSEGV 11 /* segmentation violation */
#ifndef _POSIX_SOURCE
-#define SIGSYS 12 /* non-existent system call invoked */
+#define SIGSYS 12 /* non-existent system call invoked */
#endif
-#define SIGPIPE 13 /* write on a pipe with no one to read it */
-#define SIGALRM 14 /* alarm clock */
-#define SIGTERM 15 /* software termination signal from kill */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
#ifndef _POSIX_SOURCE
-#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGURG 16 /* urgent condition on IO channel */
#endif
-#define SIGSTOP 17 /* sendable stop signal not from tty */
-#define SIGTSTP 18 /* stop signal from tty */
-#define SIGCONT 19 /* continue a stopped process */
-#define SIGCHLD 20 /* to parent on child stop or exit */
-#define SIGTTIN 21 /* to readers pgrp upon background tty read */
-#define SIGTTOU 22 /* like TTIN for output if (tp->t_local&LTOSTOP) */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN if (tp->t_local&LTOSTOP) */
#ifndef _POSIX_SOURCE
-#define SIGIO 23 /* input/output possible signal */
-#define SIGXCPU 24 /* exceeded CPU time limit */
-#define SIGXFSZ 25 /* exceeded file size limit */
-#define SIGVTALRM 26 /* virtual time alarm */
-#define SIGPROF 27 /* profiling time alarm */
-#define SIGWINCH 28 /* window size changes */
-#define SIGINFO 29 /* information request */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window size changes */
+#define SIGINFO 29 /* information request */
#endif
-#define SIGUSR1 30 /* user defined signal 1 */
-#define SIGUSR2 31 /* user defined signal 2 */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
/*-
* Type of a signal handling function.
@@ -113,56 +122,41 @@
*/
typedef void __sighandler_t __P((int));
-#if defined(_P1003_1B_VISIBLE_HISTORICALLY) || \
- (!defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE))
+#define SIG_DFL ((__sighandler_t *)0)
+#define SIG_IGN ((__sighandler_t *)1)
+#define SIG_HOLD ((__sighandler_t *)2)
+#define SIG_ERR ((__sighandler_t *)-1)
+
union sigval {
/* Members as suggested by Annex C of POSIX 1003.1b. */
- int sigval_int;
- void *sigval_ptr;
+ int sigval_int;
+ void *sigval_ptr;
};
-#endif /* !_ANSI_SOURCE && _P1003_1B_VISIBLE_HISTORICALLY */
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-/* POSIX 1003.1b required values. */
-#define SI_USER 0x10001
-#define SI_QUEUE 0x10002
-#define SI_TIMER 0x10003
-#define SI_ASYNCIO 0x10004
-#define SI_MESGQ 0x10005
-
-/* Additional FreeBSD values. */
-#define SI_UNDEFINED 0
-
-struct __siginfo {
- struct sigcontext si_sc;
- int si_signo; /* signal number */
+typedef struct {
+ int si_signo; /* signal number */
+ int si_errno; /* errno association */
/*
* Cause of signal, one of the SI_ macros or signal-specific
* values, i.e. one of the FPE_... values for SIGFPE. This
* value is equivalent to the second argument to an old-style
* FreeBSD signal handler.
*/
- int si_code;
-
- union sigval si_value;
-};
-#else /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
-struct __siginfo;
-#endif /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
-
-typedef struct __siginfo siginfo_t;
-
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
-typedef void __siginfohandler_t __P((int, siginfo_t *, void *));
-#endif /* ! _ANSI_SOURCE && ! _POSIX_SOURCE */
-
-#define SIG_DFL ((__sighandler_t *)0)
-#define SIG_IGN ((__sighandler_t *)1)
-#define SIG_ERR ((__sighandler_t *)-1)
-
-#ifndef _ANSI_SOURCE
-typedef unsigned int sigset_t;
+ int si_code; /* signal code */
+ pid_t si_pid; /* sending process */
+ uid_t si_uid; /* sender's ruid */
+ int si_status; /* exit value */
+ void *si_addr; /* faulting instruction */
+ union sigval si_value; /* signal value */
+ long si_band; /* band event for SIGPOLL */
+ int __spare__[7]; /* gimme some slack */
+} siginfo_t;
+
+typedef struct {
+ unsigned int __bits[_SIG_WORDS];
+} sigset_t;
+
+#if !defined(_ANSI_SOURCE)
/*
* Signal vector "template" used in sigaction call.
@@ -172,16 +166,19 @@ struct sigaction {
void (*__sa_handler) __P((int));
void (*__sa_sigaction) __P((int, siginfo_t *, void *));
} __sigaction_u; /* signal handler */
- sigset_t sa_mask; /* signal mask to apply */
- int sa_flags; /* see signal options below */
+ int sa_flags; /* see signal options below */
+ sigset_t sa_mask; /* signal mask to apply */
};
+
/* if SA_SIGINFO is set, sa_sigaction is to be used instead of sa_handler. */
#define sa_handler __sigaction_u.__sa_handler
-#ifndef _POSIX_SOURCE
+
+#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
+
+#if !defined(_POSIX_SOURCE)
+
#define sa_sigaction __sigaction_u.__sa_sigaction
-#endif
-#ifndef _POSIX_SOURCE
#define SA_ONSTACK 0x0001 /* take signal on signal stack */
#define SA_RESTART 0x0002 /* restart system call on signal return */
#define SA_RESETHAND 0x0004 /* reset to SIG_DFL when taking signal */
@@ -191,17 +188,21 @@ struct sigaction {
#ifdef COMPAT_SUNOS
#define SA_USERTRAMP 0x0100 /* do not bounce off kernel's sigtramp */
#endif
-#endif /* _POSIX_SOURCE */
-#define SA_NOCLDSTOP 0x0008 /* do not generate SIGCHLD on child stop */
-/*
- * Flags for sigprocmask:
- */
-#define SIG_BLOCK 1 /* block specified signal set */
-#define SIG_UNBLOCK 2 /* unblock specified signal set */
-#define SIG_SETMASK 3 /* set specified signal set */
+#define NSIG 32
+
+/* POSIX 1003.1b required values. */
+#define SI_USER 0x10001
+#define SI_QUEUE 0x10002
+#define SI_TIMER 0x10003
+#define SI_ASYNCIO 0x10004
+#define SI_MESGQ 0x10005
+
+/* Additional FreeBSD values. */
+#define SI_UNDEFINED 0
+
+typedef void __siginfohandler_t __P((int, siginfo_t *, void *));
-#ifndef _POSIX_SOURCE
typedef __sighandler_t *sig_t; /* type of pointer to a signal function */
#ifdef _BSD_SIZE_T_
@@ -210,26 +211,32 @@ typedef _BSD_SIZE_T_ size_t;
#endif
/*
- * Structure used in sigaltstack call.
+ * sigaltstack
*/
-struct sigaltstack {
- char *ss_sp; /* signal stack base */
- size_t ss_size; /* signal stack length */
- int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
-};
+typedef struct sigaltstack {
+ char *ss_sp; /* signal stack base */
+ unsigned int ss_size; /* signal stack length */
+ int ss_flags; /* SS_DISABLE and/or SS_ONSTACK */
+} stack_t;
+
#define SS_ONSTACK 0x0001 /* take signal on alternate stack */
#define SS_DISABLE 0x0004 /* disable taking signals on alternate stack */
#define MINSIGSTKSZ 8192 /* minimum allowable stack */
#define SIGSTKSZ (MINSIGSTKSZ + 32768) /* recommended stack size */
/*
+ * Suck in definition of ucontext_t
+ */
+#include <sys/ucontext.h>
+
+/*
* 4.3 compatibility:
* Signal vector "template" used in sigvec call.
*/
struct sigvec {
- __sighandler_t *sv_handler; /* signal handler */
- int sv_mask; /* signal mask to apply */
- int sv_flags; /* see signal options below */
+ __sighandler_t *sv_handler; /* signal handler */
+ int sv_mask; /* signal mask to apply */
+ int sv_flags; /* see signal options below */
};
#define SV_ONSTACK SA_ONSTACK
@@ -244,8 +251,8 @@ struct sigvec {
* Structure used in sigstack call.
*/
struct sigstack {
- char *ss_sp; /* signal stack pointer */
- int ss_onstack; /* current status */
+ char *ss_sp; /* signal stack pointer */
+ int ss_onstack; /* current status */
};
/*
@@ -256,21 +263,25 @@ struct sigstack {
#define BADSIG SIG_ERR
-#endif /* !_POSIX_SOURCE */
-#endif /* !_ANSI_SOURCE */
+#endif /* !_POSIX_SOURCE */
-#if !defined(_ANSI_SOURCE) && defined(_P1003_1B_VISIBLE_HISTORICALLY)
+/*
+ * Flags for sigprocmask:
+ */
+#define SIG_BLOCK 1 /* block specified signal set */
+#define SIG_UNBLOCK 2 /* unblock specified signal set */
+#define SIG_SETMASK 3 /* set specified signal set */
struct sigevent {
- int sigev_notify; /* Notification type */
- int sigev_signo; /* Signal number */
- union sigval sigev_value; /* Signal value */
+ int sigev_notify; /* Notification type */
+ int sigev_signo; /* Signal number */
+ union sigval sigev_value; /* Signal value */
};
#define SIGEV_NONE 0 /* No async notification */
#define SIGEV_SIGNAL 1 /* Generate a queued signal */
-#endif /* ! _ANSI_SOURCE && _P1003_1B_VISIBLE_HISTORICALLY */
+#endif /* !_ANSI_SOURCE */
/*
* For historical reasons; programs expect signal's return value to be
diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h
index b3da667..99b26bd 100644
--- a/sys/sys/signalvar.h
+++ b/sys/sys/signalvar.h
@@ -38,26 +38,29 @@
#define _SYS_SIGNALVAR_H_
#include <sys/signal.h>
+#include <sys/proc.h>
/*
* Kernel signal definitions and data structures,
* not exported to user programs.
*/
+int __sigisempty __P((sigset_t *set));
+int __sigseteq __P((sigset_t *set1, sigset_t *set2));
/*
* Process signal actions and state, needed only within the process
* (not necessarily resident).
*/
struct sigacts {
- sig_t ps_sigact[NSIG]; /* disposition of signals */
- sigset_t ps_catchmask[NSIG]; /* signals to be blocked */
+ sig_t ps_sigact[_SIG_MAXSIG]; /* disposition of signals */
+ sigset_t ps_catchmask[_SIG_MAXSIG]; /* signals to be blocked */
sigset_t ps_sigonstack; /* signals to take on sigstack */
sigset_t ps_sigintr; /* signals that interrupt syscalls */
sigset_t ps_sigreset; /* signals that reset when caught */
sigset_t ps_signodefer; /* signals not masked while handled */
sigset_t ps_siginfo; /* signals that want SA_SIGINFO args */
int ps_flags; /* signal flags, below */
- struct sigaltstack ps_sigstk; /* sp & on stack state variable */
+ stack_t ps_sigstk; /* sp & on stack state variable */
sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */
};
@@ -65,89 +68,131 @@ struct sigacts {
#define SAS_OLDMASK 0x01 /* need to restore mask before pause */
#define SAS_ALTSTACK 0x02 /* have alternate signal stack */
-/* additional signal action values, used only temporarily/internally */
-#define SIG_CATCH ((__sighandler_t *)2)
-#define SIG_HOLD ((__sighandler_t *)3)
-
/*
- * get signal action for process and signal; currently only for current process
+ * Compatibility
*/
-#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[(sig)])
+typedef struct {
+ struct osigcontext si_sc;
+ int si_signo;
+ int si_code;
+ union sigval si_value;
+} osiginfo_t;
+
+struct osigaction {
+ union {
+ void (*__sa_handler) __P((int));
+ void (*__sa_sigaction) __P((int, osiginfo_t *, void *));
+ } __sigaction_u; /* signal handler */
+ osigset_t sa_mask; /* signal mask to apply */
+ int sa_flags; /* see signal options below */
+};
+
+typedef void __osiginfohandler_t __P((int, osiginfo_t *, void *));
/*
- * Determine signal that should be delivered to process p, the current
- * process, 0 if none. If there is a pending stop signal with default
- * action, the process stops in issignal().
+ * additional signal action values, used only temporarily/internally
+ * NOTE: SIG_HOLD was previously internal only, but has been moved to
+ * sys/signal.h
*/
-#define CURSIG(p) \
- (((p)->p_siglist == 0 || \
- (((p)->p_flag & P_TRACED) == 0 && \
- ((p)->p_siglist & ~(p)->p_sigmask) == 0)) ? \
- 0 : issignal(p))
+#define SIG_CATCH ((__sighandler_t *)3)
/*
- * Clear a pending signal from a process.
+ * get signal action for process and signal; currently only for current process
*/
-#define CLRSIG(p, sig) { (p)->p_siglist &= ~sigmask(sig); }
+#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[_SIG_IDX(sig)])
/*
- * Signal properties and actions.
- * The array below categorizes the signals and their default actions
- * according to the following properties:
+ * sigset_t manipulation macros
*/
-#define SA_KILL 0x01 /* terminates process by default */
-#define SA_CORE 0x02 /* ditto and coredumps */
-#define SA_STOP 0x04 /* suspend process */
-#define SA_TTYSTOP 0x08 /* ditto, from tty */
-#define SA_IGNORE 0x10 /* ignore by default */
-#define SA_CONT 0x20 /* continue if suspended */
-#define SA_CANTMASK 0x40 /* non-maskable, catchable */
-
-#ifdef SIGPROP
-static int sigprop[NSIG + 1] = {
- 0, /* unused */
- SA_KILL, /* SIGHUP */
- SA_KILL, /* SIGINT */
- SA_KILL|SA_CORE, /* SIGQUIT */
- SA_KILL|SA_CORE, /* SIGILL */
- SA_KILL|SA_CORE, /* SIGTRAP */
- SA_KILL|SA_CORE, /* SIGABRT */
- SA_KILL|SA_CORE, /* SIGEMT */
- SA_KILL|SA_CORE, /* SIGFPE */
- SA_KILL, /* SIGKILL */
- SA_KILL|SA_CORE, /* SIGBUS */
- SA_KILL|SA_CORE, /* SIGSEGV */
- SA_KILL|SA_CORE, /* SIGSYS */
- SA_KILL, /* SIGPIPE */
- SA_KILL, /* SIGALRM */
- SA_KILL, /* SIGTERM */
- SA_IGNORE, /* SIGURG */
- SA_STOP, /* SIGSTOP */
- SA_STOP|SA_TTYSTOP, /* SIGTSTP */
- SA_IGNORE|SA_CONT, /* SIGCONT */
- SA_IGNORE, /* SIGCHLD */
- SA_STOP|SA_TTYSTOP, /* SIGTTIN */
- SA_STOP|SA_TTYSTOP, /* SIGTTOU */
- SA_IGNORE, /* SIGIO */
- SA_KILL, /* SIGXCPU */
- SA_KILL, /* SIGXFSZ */
- SA_KILL, /* SIGVTALRM */
- SA_KILL, /* SIGPROF */
- SA_IGNORE, /* SIGWINCH */
- SA_IGNORE, /* SIGINFO */
- SA_KILL, /* SIGUSR1 */
- SA_KILL, /* SIGUSR2 */
-};
-
-#define contsigmask (sigmask(SIGCONT))
-#define stopsigmask (sigmask(SIGSTOP) | sigmask(SIGTSTP) | \
- sigmask(SIGTTIN) | sigmask(SIGTTOU))
-
-#endif /* SIGPROP */
-
-#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
+#define SIGADDSET(set, signo) \
+ (set).__bits[_SIG_WORD(signo)] |= _SIG_BIT(signo)
+
+#define SIGDELSET(set, signo) \
+ (set).__bits[_SIG_WORD(signo)] &= ~_SIG_BIT(signo)
+
+#define SIGEMPTYSET(set) \
+ do { \
+ int __i; \
+ for (__i = 0; __i < _SIG_WORDS; __i++) \
+ (set).__bits[__i] = 0; \
+ } while (0)
+
+#define SIGFILLSET(set) \
+ do { \
+ int __i; \
+ for (__i = 0; __i < _SIG_WORDS; __i++) \
+ (set).__bits[__i] = ~(unsigned int)0; \
+ } while (0)
+
+#define SIGISMEMBER(set, signo) \
+ ((set).__bits[_SIG_WORD(signo)] & _SIG_BIT(signo))
+
+#define SIGISEMPTY(set) __sigisempty(&(set))
+#define SIGNOTEMPTY(set) (!__sigisempty(&(set)))
+
+#define SIGSETEQ(set1, set2) __sigseteq(&(set1), &(set2))
+#define SIGSETNEQ(set1, set2) (!__sigseteq(&(set1), &(set2)))
+
+#define SIGSETOR(set1, set2) \
+ do { \
+ int __i; \
+ for (__i = 0; __i < _SIG_WORDS; __i++) \
+ (set1).__bits[__i] |= (set2).__bits[__i]; \
+ } while (0)
+
+#define SIGSETAND(set1, set2) \
+ do { \
+ int __i; \
+ for (__i = 0; __i < _SIG_WORDS; __i++) \
+ (set1).__bits[__i] &= (set2).__bits[__i]; \
+ } while (0)
+
+#define SIGSETNAND(set1, set2) \
+ do { \
+ int __i; \
+ for (__i = 0; __i < _SIG_WORDS; __i++) \
+ (set1).__bits[__i] &= ~(set2).__bits[__i]; \
+ } while (0)
+
+#define SIG_CANTMASK(set) \
+ SIGDELSET(set, SIGKILL), SIGDELSET(set, SIGSTOP)
+
+#define SIG_STOPSIGMASK(set) \
+ SIGDELSET(set, SIGSTOP), SIGDELSET(set, SIGTSTP), \
+ SIGDELSET(set, SIGTTIN), SIGDELSET(set, SIGTTOU)
+
+#define SIG_CONTSIGMASK(set) \
+ SIGDELSET(set, SIGCONT)
+
+#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP))
+
+#define SIG2OSIG(sig, osig) osig = (sig).__bits[0]
+#define OSIG2SIG(osig, sig) SIGEMPTYSET(sig); (sig).__bits[0] = osig
+
+extern __inline int __sigisempty(sigset_t *set)
+{
+ int i;
+
+ for (i = 0; i < _SIG_WORDS; i++) {
+ if (set->__bits[i])
+ return (0);
+ }
+ return (1);
+}
+
+extern __inline int __sigseteq(sigset_t *set1, sigset_t *set2)
+{
+ int i;
+
+ for (i = 0; i < _SIG_WORDS; i++) {
+ if (set1->__bits[i] != set2->__bits[i])
+ return (0);
+ }
+ return (1);
+}
#ifdef KERNEL
+
struct pgrp;
struct proc;
struct sigio;
@@ -168,10 +213,37 @@ void psignal __P((struct proc *p, int sig));
void sigexit __P((struct proc *p, int signum));
void siginit __P((struct proc *p));
void trapsignal __P((struct proc *p, int sig, u_long code));
-void check_sigacts (void);
+void check_sigacts __P((void));
+int __sig_ffs __P((sigset_t *set));
+int __cursig __P((struct proc *p));
+
/*
* Machine-dependent functions:
*/
-void sendsig __P((sig_t action, int sig, int returnmask, u_long code));
+void sendsig __P((sig_t action, int sig, sigset_t *retmask, u_long code));
+int md_sigreturn __P((struct proc *p, void *sigcntxp, sigset_t *mask));
+
+/*
+ * Inline functions:
+ */
+#define CURSIG(p) __cursig(p)
+
+/*
+ * Determine signal that should be delivered to process p, the current
+ * process, 0 if none. If there is a pending stop signal with default
+ * action, the process stops in issignal().
+ */
+extern __inline int __cursig(struct proc *p)
+{
+ sigset_t tmpset;
+
+ tmpset = p->p_siglist;
+ SIGSETNAND(tmpset, p->p_sigmask);
+ return ((SIGISEMPTY(p->p_siglist) ||
+ (!(p->p_flag & P_TRACED) && SIGISEMPTY(tmpset)))
+ ? 0 : issignal(p));
+}
+
#endif /* KERNEL */
+
#endif /* !_SYS_SIGNALVAR_H_ */
diff --git a/sys/sys/syscall-hide.h b/sys/sys/syscall-hide.h
index 39a35ca..2ece27a 100644
--- a/sys/sys/syscall-hide.h
+++ b/sys/sys/syscall-hide.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.64 1999/09/11 00:45:58 alfred Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.65 1999/09/29 15:01:21 marcel Exp
*/
HIDE_POSIX(fork)
@@ -49,13 +49,13 @@ HIDE_POSIX(pipe)
HIDE_POSIX(getegid)
HIDE_BSD(profil)
HIDE_BSD(ktrace)
-HIDE_POSIX(sigaction)
+HIDE_POSIX(osigaction)
HIDE_POSIX(getgid)
-HIDE_POSIX(sigprocmask)
+HIDE_POSIX(osigprocmask)
HIDE_BSD(getlogin)
HIDE_BSD(setlogin)
HIDE_BSD(acct)
-HIDE_POSIX(sigpending)
+HIDE_POSIX(osigpending)
HIDE_BSD(sigaltstack)
HIDE_POSIX(ioctl)
HIDE_BSD(reboot)
@@ -102,14 +102,14 @@ HIDE_BSD(accept)
HIDE_BSD(getpriority)
HIDE_BSD(send)
HIDE_BSD(recv)
-HIDE_BSD(sigreturn)
+HIDE_BSD(osigreturn)
HIDE_BSD(bind)
HIDE_BSD(setsockopt)
HIDE_BSD(listen)
HIDE_BSD(sigvec)
HIDE_BSD(sigblock)
HIDE_BSD(sigsetmask)
-HIDE_POSIX(sigsuspend)
+HIDE_POSIX(osigsuspend)
HIDE_BSD(sigstack)
HIDE_BSD(recvmsg)
HIDE_BSD(sendmsg)
@@ -257,3 +257,8 @@ HIDE_BSD(sendfile)
HIDE_BSD(kldsym)
HIDE_BSD(jail)
HIDE_BSD(pioctl)
+HIDE_POSIX(sigprocmask)
+HIDE_POSIX(sigsuspend)
+HIDE_POSIX(sigaction)
+HIDE_POSIX(sigpending)
+HIDE_BSD(sigreturn)
diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h
index ea52b4b9..555e5e0 100644
--- a/sys/sys/syscall.h
+++ b/sys/sys/syscall.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.64 1999/09/11 00:45:58 alfred Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.65 1999/09/29 15:01:21 marcel Exp
*/
#define SYS_syscall 0
@@ -52,13 +52,13 @@
#define SYS_getegid 43
#define SYS_profil 44
#define SYS_ktrace 45
-#define SYS_sigaction 46
+#define SYS_osigaction 46
#define SYS_getgid 47
-#define SYS_sigprocmask 48
+#define SYS_osigprocmask 48
#define SYS_getlogin 49
#define SYS_setlogin 50
#define SYS_acct 51
-#define SYS_sigpending 52
+#define SYS_osigpending 52
#define SYS_sigaltstack 53
#define SYS_ioctl 54
#define SYS_reboot 55
@@ -107,7 +107,7 @@
#define SYS_getpriority 100
/* 101 is old send */
/* 102 is old recv */
-#define SYS_sigreturn 103
+#define SYS_osigreturn 103
#define SYS_bind 104
#define SYS_setsockopt 105
#define SYS_listen 106
@@ -115,7 +115,7 @@
/* 108 is old sigvec */
/* 109 is old sigblock */
/* 110 is old sigsetmask */
-#define SYS_sigsuspend 111
+#define SYS_osigsuspend 111
/* 112 is old sigstack */
/* 113 is old recvmsg */
/* 114 is old sendmsg */
@@ -262,4 +262,9 @@
#define SYS_sendfile 336
#define SYS_kldsym 337
#define SYS_jail 338
-#define SYS_MAXSYSCALL 340
+#define SYS_sigprocmask 340
+#define SYS_sigsuspend 341
+#define SYS_sigaction 342
+#define SYS_sigpending 343
+#define SYS_sigreturn 344
+#define SYS_MAXSYSCALL 347
diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk
index 1ec08c9..abc1835 100644
--- a/sys/sys/syscall.mk
+++ b/sys/sys/syscall.mk
@@ -1,7 +1,7 @@
# FreeBSD system call names.
# DO NOT EDIT-- this file is automatically generated.
# $FreeBSD$
-# created from FreeBSD: src/sys/kern/syscalls.master,v 1.64 1999/09/11 00:45:58 alfred Exp
+# created from FreeBSD: src/sys/kern/syscalls.master,v 1.65 1999/09/29 15:01:21 marcel Exp
MIASM = \
syscall.o \
exit.o \
@@ -44,13 +44,13 @@ MIASM = \
getegid.o \
profil.o \
ktrace.o \
- sigaction.o \
+ osigaction.o \
getgid.o \
- sigprocmask.o \
+ osigprocmask.o \
getlogin.o \
setlogin.o \
acct.o \
- sigpending.o \
+ osigpending.o \
sigaltstack.o \
ioctl.o \
reboot.o \
@@ -85,11 +85,11 @@ MIASM = \
socket.o \
connect.o \
getpriority.o \
- sigreturn.o \
+ osigreturn.o \
bind.o \
setsockopt.o \
listen.o \
- sigsuspend.o \
+ osigsuspend.o \
gettimeofday.o \
getrusage.o \
getsockopt.o \
@@ -217,4 +217,9 @@ MIASM = \
utrace.o \
sendfile.o \
kldsym.o \
- jail.o
+ jail.o \
+ sigprocmask.o \
+ sigsuspend.o \
+ sigaction.o \
+ sigpending.o \
+ sigreturn.o
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index 9fc634c..7ff638d 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -36,6 +36,8 @@
#ifndef _SYS_SYSENT_H_
#define _SYS_SYSENT_H_
+#include <sys/signal.h>
+
struct proc;
typedef int sy_call_t __P((struct proc *, void *));
@@ -63,7 +65,7 @@ struct sysentvec {
/* translate trap-to-signal mapping */
int (*sv_fixup) __P((long **, struct image_params *));
/* stack fixup function */
- void (*sv_sendsig) __P((void (*)(int), int, int, u_long));
+ void (*sv_sendsig) __P((void (*)(int), int, sigset_t *, u_long));
/* send signal */
char *sv_sigcode; /* start of sigtramp code */
int *sv_szsigcode; /* size of sigtramp code */
diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h
index 530ba1a..d80e69c 100644
--- a/sys/sys/sysproto.h
+++ b/sys/sys/sysproto.h
@@ -3,7 +3,7 @@
*
* DO NOT EDIT-- this file is automatically generated.
* $FreeBSD$
- * created from FreeBSD: src/sys/kern/syscalls.master,v 1.64 1999/09/11 00:45:58 alfred Exp
+ * created from FreeBSD: src/sys/kern/syscalls.master,v 1.65 1999/09/29 15:01:21 marcel Exp
*/
#ifndef _SYS_SYSPROTO_H_
@@ -188,17 +188,17 @@ struct ktrace_args {
int facs; char facs_[PAD_(int)];
int pid; char pid_[PAD_(int)];
};
-struct sigaction_args {
+struct osigaction_args {
int signum; char signum_[PAD_(int)];
- struct sigaction * nsa; char nsa_[PAD_(struct sigaction *)];
- struct sigaction * osa; char osa_[PAD_(struct sigaction *)];
+ struct osigaction * nsa; char nsa_[PAD_(struct osigaction *)];
+ struct osigaction * osa; char osa_[PAD_(struct osigaction *)];
};
struct getgid_args {
register_t dummy;
};
-struct sigprocmask_args {
+struct osigprocmask_args {
int how; char how_[PAD_(int)];
- sigset_t mask; char mask_[PAD_(sigset_t)];
+ osigset_t mask; char mask_[PAD_(osigset_t)];
};
struct getlogin_args {
char * namebuf; char namebuf_[PAD_(char *)];
@@ -210,12 +210,12 @@ struct setlogin_args {
struct acct_args {
char * path; char path_[PAD_(char *)];
};
-struct sigpending_args {
+struct osigpending_args {
register_t dummy;
};
struct sigaltstack_args {
- struct sigaltstack * nss; char nss_[PAD_(struct sigaltstack *)];
- struct sigaltstack * oss; char oss_[PAD_(struct sigaltstack *)];
+ stack_t * ss; char ss_[PAD_(stack_t *)];
+ stack_t * oss; char oss_[PAD_(stack_t *)];
};
struct ioctl_args {
int fd; char fd_[PAD_(int)];
@@ -358,8 +358,8 @@ struct getpriority_args {
int which; char which_[PAD_(int)];
int who; char who_[PAD_(int)];
};
-struct sigreturn_args {
- struct sigcontext * sigcntxp; char sigcntxp_[PAD_(struct sigcontext *)];
+struct osigreturn_args {
+ struct osigcontext * sigcntxp; char sigcntxp_[PAD_(struct osigcontext *)];
};
struct bind_args {
int s; char s_[PAD_(int)];
@@ -377,8 +377,8 @@ struct listen_args {
int s; char s_[PAD_(int)];
int backlog; char backlog_[PAD_(int)];
};
-struct sigsuspend_args {
- sigset_t mask; char mask_[PAD_(sigset_t)];
+struct osigsuspend_args {
+ osigset_t mask; char mask_[PAD_(osigset_t)];
};
struct gettimeofday_args {
struct timeval * tp; char tp_[PAD_(struct timeval *)];
@@ -923,6 +923,25 @@ struct kldsym_args {
struct jail_args {
struct jail * jail; char jail_[PAD_(struct jail *)];
};
+struct sigprocmask_args {
+ int how; char how_[PAD_(int)];
+ const sigset_t * set; char set_[PAD_(const sigset_t *)];
+ sigset_t * oset; char oset_[PAD_(sigset_t *)];
+};
+struct sigsuspend_args {
+ const sigset_t * sigmask; char sigmask_[PAD_(const sigset_t *)];
+};
+struct sigaction_args {
+ int sig; char sig_[PAD_(int)];
+ const struct sigaction * act; char act_[PAD_(const struct sigaction *)];
+ struct sigaction * oact; char oact_[PAD_(struct sigaction *)];
+};
+struct sigpending_args {
+ sigset_t * set; char set_[PAD_(sigset_t *)];
+};
+struct sigreturn_args {
+ ucontext_t * sigcntxp; char sigcntxp_[PAD_(ucontext_t *)];
+};
int nosys __P((struct proc *, struct nosys_args *));
void exit __P((struct proc *, struct rexit_args *)) __dead2;
int fork __P((struct proc *, struct fork_args *));
@@ -964,13 +983,13 @@ int pipe __P((struct proc *, struct pipe_args *));
int getegid __P((struct proc *, struct getegid_args *));
int profil __P((struct proc *, struct profil_args *));
int ktrace __P((struct proc *, struct ktrace_args *));
-int sigaction __P((struct proc *, struct sigaction_args *));
+int osigaction __P((struct proc *, struct osigaction_args *));
int getgid __P((struct proc *, struct getgid_args *));
-int sigprocmask __P((struct proc *, struct sigprocmask_args *));
+int osigprocmask __P((struct proc *, struct osigprocmask_args *));
int getlogin __P((struct proc *, struct getlogin_args *));
int setlogin __P((struct proc *, struct setlogin_args *));
int acct __P((struct proc *, struct acct_args *));
-int sigpending __P((struct proc *, struct sigpending_args *));
+int osigpending __P((struct proc *, struct osigpending_args *));
int sigaltstack __P((struct proc *, struct sigaltstack_args *));
int ioctl __P((struct proc *, struct ioctl_args *));
int reboot __P((struct proc *, struct reboot_args *));
@@ -1005,11 +1024,11 @@ int setpriority __P((struct proc *, struct setpriority_args *));
int socket __P((struct proc *, struct socket_args *));
int connect __P((struct proc *, struct connect_args *));
int getpriority __P((struct proc *, struct getpriority_args *));
-int sigreturn __P((struct proc *, struct sigreturn_args *));
+int osigreturn __P((struct proc *, struct osigreturn_args *));
int bind __P((struct proc *, struct bind_args *));
int setsockopt __P((struct proc *, struct setsockopt_args *));
int listen __P((struct proc *, struct listen_args *));
-int sigsuspend __P((struct proc *, struct sigsuspend_args *));
+int osigsuspend __P((struct proc *, struct osigsuspend_args *));
int gettimeofday __P((struct proc *, struct gettimeofday_args *));
int getrusage __P((struct proc *, struct getrusage_args *));
int getsockopt __P((struct proc *, struct getsockopt_args *));
@@ -1136,6 +1155,11 @@ int utrace __P((struct proc *, struct utrace_args *));
int sendfile __P((struct proc *, struct sendfile_args *));
int kldsym __P((struct proc *, struct kldsym_args *));
int jail __P((struct proc *, struct jail_args *));
+int sigprocmask __P((struct proc *, struct sigprocmask_args *));
+int sigsuspend __P((struct proc *, struct sigsuspend_args *));
+int sigaction __P((struct proc *, struct sigaction_args *));
+int sigpending __P((struct proc *, struct sigpending_args *));
+int sigreturn __P((struct proc *, struct sigreturn_args *));
#ifdef COMPAT_43
diff --git a/sys/sys/ucontext.h b/sys/sys/ucontext.h
new file mode 100644
index 0000000..fda8bcd
--- /dev/null
+++ b/sys/sys/ucontext.h
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 1999 Marcel Moolenaar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in this position and unchanged.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _SYS_UCONTEXT_H_
+#define _SYS_UCONTEXT_H_ 1
+
+#include <machine/ucontext.h>
+
+typedef struct __ucontext {
+ struct __ucontext *uc_link;
+ stack_t uc_stack;
+ sigset_t uc_sigmask;
+ mcontext_t uc_mcontext;
+ int __spare__[8];
+} ucontext_t;
+
+#endif /* _SYS_UCONTEXT_H_ */
diff --git a/sys/ufs/mfs/mfs_vfsops.c b/sys/ufs/mfs/mfs_vfsops.c
index 9188837..0355d57 100644
--- a/sys/ufs/mfs/mfs_vfsops.c
+++ b/sys/ufs/mfs/mfs_vfsops.c
@@ -410,7 +410,7 @@ mfs_start(mp, flags, p)
register struct vnode *vp = VFSTOUFS(mp)->um_devvp;
register struct mfsnode *mfsp = VTOMFS(vp);
register struct buf *bp;
- register int gotsig = 0;
+ register int gotsig = 0, sig;
/*
* We must prevent the system from trying to swap
@@ -449,8 +449,11 @@ mfs_start(mp, flags, p)
*/
if (gotsig) {
gotsig = 0;
- if (dounmount(mp, 0, p) != 0)
- CLRSIG(p, CURSIG(p)); /* try sleep again.. */
+ if (dounmount(mp, 0, p) != 0) {
+ sig = CURSIG(p);
+ if (sig)
+ SIGDELSET(p->p_siglist, sig);
+ }
}
else if (tsleep((caddr_t)vp, mfs_pri, "mfsidl", 0))
gotsig++; /* try to unmount in next pass */
OpenPOWER on IntegriCloud