BSD 4_3_Reno release
[unix-history] / usr / src / sys / kern / kern_sig.c
index d051018..a271cdc 100644 (file)
@@ -2,24 +2,27 @@
  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * Redistribution is only permitted until one year after the first shipment
+ * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
+ * binary forms are permitted provided that: (1) source distributions retain
+ * this entire copyright notice and comment, and (2) distributions including
+ * binaries display the following acknowledgement:  This product includes
+ * software developed by the University of California, Berkeley and its
+ * contributors'' in the documentation or other materials provided with the
+ * distribution and in all advertising materials mentioning features or use
+ * of this software.  Neither the name of the University nor the names of
+ * its contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  *
- *     @(#)kern_sig.c  7.20 (Berkeley) %G%
+ *     @(#)kern_sig.c  7.23 (Berkeley) 6/28/90
  */
 
 #include "param.h"
 #include "systm.h"
  */
 
 #include "param.h"
 #include "systm.h"
-#include "syscontext.h"        /* XXX */
+#include "user.h"
 #include "vnode.h"
 #include "proc.h"
 #include "timeb.h"
 #include "vnode.h"
 #include "proc.h"
 #include "timeb.h"
@@ -71,7 +74,7 @@ sigaction(p, uap, retval)
 
        sig = uap->signo;
        if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
 
        sig = uap->signo;
        if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
-               RETURN (EINVAL);
+               return (EINVAL);
        sa = &vec;
        if (uap->osa) {
                sa->sa_handler = u.u_signal[sig];
        sa = &vec;
        if (uap->osa) {
                sa->sa_handler = u.u_signal[sig];
@@ -86,15 +89,15 @@ sigaction(p, uap, retval)
                        sa->sa_flags |= SA_NOCLDSTOP;
                if (error = copyout((caddr_t)sa, (caddr_t)uap->osa,
                    sizeof (vec)))
                        sa->sa_flags |= SA_NOCLDSTOP;
                if (error = copyout((caddr_t)sa, (caddr_t)uap->osa,
                    sizeof (vec)))
-                       RETURN (error);
+                       return (error);
        }
        if (uap->nsa) {
                if (error = copyin((caddr_t)uap->nsa, (caddr_t)sa,
                    sizeof (vec)))
        }
        if (uap->nsa) {
                if (error = copyin((caddr_t)uap->nsa, (caddr_t)sa,
                    sizeof (vec)))
-                       RETURN (error);
+                       return (error);
                setsigvec(p, sig, sa);
        }
                setsigvec(p, sig, sa);
        }
-       RETURN (0);
+       return (0);
 }
 
 setsigvec(p, sig, sa)
 }
 
 setsigvec(p, sig, sa)
@@ -228,7 +231,7 @@ sigprocmask(p, uap, retval)
                break;
        }
        (void) spl0();
                break;
        }
        (void) spl0();
-       RETURN (error);
+       return (error);
 }
 
 /* ARGSUSED */
 }
 
 /* ARGSUSED */
@@ -239,7 +242,7 @@ sigpending(p, uap, retval)
 {
 
        *retval = p->p_sig;
 {
 
        *retval = p->p_sig;
-       RETURN (0);
+       return (0);
 }
 
 #ifdef COMPAT_43
 }
 
 #ifdef COMPAT_43
@@ -263,7 +266,7 @@ osigvec(p, uap, retval)
 
        sig = uap->signo;
        if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
 
        sig = uap->signo;
        if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
-               RETURN (EINVAL);
+               return (EINVAL);
        sv = &vec;
        if (uap->osv) {
                *(sig_t *)&sv->sv_handler = u.u_signal[sig];
        sv = &vec;
        if (uap->osv) {
                *(sig_t *)&sv->sv_handler = u.u_signal[sig];
@@ -278,16 +281,16 @@ osigvec(p, uap, retval)
                        sv->sv_flags |= SA_NOCLDSTOP;
                if (error = copyout((caddr_t)sv, (caddr_t)uap->osv,
                    sizeof (vec)))
                        sv->sv_flags |= SA_NOCLDSTOP;
                if (error = copyout((caddr_t)sv, (caddr_t)uap->osv,
                    sizeof (vec)))
-                       RETURN (error);
+                       return (error);
        }
        if (uap->nsv) {
                if (error = copyin((caddr_t)uap->nsv, (caddr_t)sv,
                    sizeof (vec)))
        }
        if (uap->nsv) {
                if (error = copyin((caddr_t)uap->nsv, (caddr_t)sv,
                    sizeof (vec)))
-                       RETURN (error);
+                       return (error);
                sv->sv_flags ^= SA_RESTART;     /* opposite of SV_INTERRUPT */
                setsigvec(p, sig, (struct sigaction *)sv);
        }
                sv->sv_flags ^= SA_RESTART;     /* opposite of SV_INTERRUPT */
                setsigvec(p, sig, (struct sigaction *)sv);
        }
-       RETURN (0);
+       return (0);
 }
 
 osigblock(p, uap, retval)
 }
 
 osigblock(p, uap, retval)
@@ -302,7 +305,7 @@ osigblock(p, uap, retval)
        *retval = p->p_sigmask;
        p->p_sigmask |= uap->mask &~ sigcantmask;
        (void) spl0();
        *retval = p->p_sigmask;
        p->p_sigmask |= uap->mask &~ sigcantmask;
        (void) spl0();
-       RETURN (0);
+       return (0);
 }
 
 osigsetmask(p, uap, retval)
 }
 
 osigsetmask(p, uap, retval)
@@ -317,7 +320,7 @@ osigsetmask(p, uap, retval)
        *retval = p->p_sigmask;
        p->p_sigmask = uap->mask &~ sigcantmask;
        (void) spl0();
        *retval = p->p_sigmask;
        p->p_sigmask = uap->mask &~ sigcantmask;
        (void) spl0();
-       RETURN (0);
+       return (0);
 }
 #endif
 
 }
 #endif
 
@@ -347,7 +350,7 @@ sigsuspend(p, uap, retval)
        p->p_sigmask = uap->mask &~ sigcantmask;
        (void) tsleep((caddr_t)&u, PPAUSE | PCATCH, "pause", 0);
        /* always return EINTR rather than ERESTART... */
        p->p_sigmask = uap->mask &~ sigcantmask;
        (void) tsleep((caddr_t)&u, PPAUSE | PCATCH, "pause", 0);
        /* always return EINTR rather than ERESTART... */
-       RETURN (EINTR);
+       return (EINTR);
 }
 
 /* ARGSUSED */
 }
 
 /* ARGSUSED */
@@ -364,11 +367,11 @@ sigstack(p, uap, retval)
 
        if (uap->oss && (error = copyout((caddr_t)&u.u_sigstack,
            (caddr_t)uap->oss, sizeof (struct sigstack))))
 
        if (uap->oss && (error = copyout((caddr_t)&u.u_sigstack,
            (caddr_t)uap->oss, sizeof (struct sigstack))))
-               RETURN (error);
+               return (error);
        if (uap->nss && (error = copyin((caddr_t)uap->nss, (caddr_t)&ss,
            sizeof (ss))) == 0)
                u.u_sigstack = ss;
        if (uap->nss && (error = copyin((caddr_t)uap->nss, (caddr_t)&ss,
            sizeof (ss))) == 0)
                u.u_sigstack = ss;
-       RETURN (error);
+       return (error);
 }
 
 /* ARGSUSED */
 }
 
 /* ARGSUSED */
@@ -383,25 +386,25 @@ kill(cp, uap, retval)
        register struct proc *p;
 
        if ((unsigned) uap->signo >= NSIG)
        register struct proc *p;
 
        if ((unsigned) uap->signo >= NSIG)
-               RETURN (EINVAL);
+               return (EINVAL);
        if (uap->pid > 0) {
                /* kill single process */
                p = pfind(uap->pid);
                if (p == 0)
        if (uap->pid > 0) {
                /* kill single process */
                p = pfind(uap->pid);
                if (p == 0)
-                       RETURN (ESRCH);
+                       return (ESRCH);
                if (!CANSIGNAL(cp, p, uap->signo))
                if (!CANSIGNAL(cp, p, uap->signo))
-                       RETURN (EPERM);
+                       return (EPERM);
                if (uap->signo)
                        psignal(p, uap->signo);
                if (uap->signo)
                        psignal(p, uap->signo);
-               RETURN (0);
+               return (0);
        }
        switch (uap->pid) {
        case -1:                /* broadcast signal */
        }
        switch (uap->pid) {
        case -1:                /* broadcast signal */
-               RETURN (killpg1(cp, uap->signo, 0, 1));
+               return (killpg1(cp, uap->signo, 0, 1));
        case 0:                 /* signal own process group */
        case 0:                 /* signal own process group */
-               RETURN (killpg1(cp, uap->signo, 0, 0));
+               return (killpg1(cp, uap->signo, 0, 0));
        default:                /* negative explicit process group */
        default:                /* negative explicit process group */
-               RETURN (killpg1(cp, uap->signo, -uap->pid, 0));
+               return (killpg1(cp, uap->signo, -uap->pid, 0));
        }
        /* NOTREACHED */
 }
        }
        /* NOTREACHED */
 }
@@ -418,8 +421,8 @@ okillpg(p, uap, retval)
 {
 
        if ((unsigned) uap->signo >= NSIG)
 {
 
        if ((unsigned) uap->signo >= NSIG)
-               RETURN (EINVAL);
-       RETURN (killpg1(p, uap->signo, uap->pgid, 0));
+               return (EINVAL);
+       return (killpg1(p, uap->signo, uap->pgid, 0));
 }
 #endif
 
 }
 #endif
 
@@ -523,7 +526,7 @@ trapsignal(sig, code)
                sendsig(u.u_signal[sig], sig, p->p_sigmask, code);
                p->p_sigmask |= u.u_sigmask[sig] | mask;
        } else {
                sendsig(u.u_signal[sig], sig, p->p_sigmask, code);
                p->p_sigmask |= u.u_sigmask[sig] | mask;
        } else {
-               u.u_arg[1] = code;      /* XXX for core dump/debugger */
+               u.u_code = code;        /* XXX for core dump/debugger */
                psignal(p, sig);
        }
 }
                psignal(p, sig);
        }
 }
@@ -639,7 +642,7 @@ psignal(p, sig)
                        if (p->p_flag&SVFORK)
                                goto out;
                        p->p_sig &= ~mask;
                        if (p->p_flag&SVFORK)
                                goto out;
                        p->p_sig &= ~mask;
-                       p->p_cursig = sig;
+                       p->p_xstat = sig;
                        if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
                                psignal(p->p_pptr, SIGCHLD);
                        stop(p);
                        if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
                                psignal(p->p_pptr, SIGCHLD);
                        stop(p);
@@ -674,7 +677,6 @@ psignal(p, sig)
                         * an event, then it goes back to run state.
                         * Otherwise, process goes back to sleep state.
                         */
                         * an event, then it goes back to run state.
                         * Otherwise, process goes back to sleep state.
                         */
-                       p->p_cursig = 0;        /* ??? XXX */
                        if (action == SIG_DFL)
                                p->p_sig &= ~mask;
                        if (action == SIG_CATCH)
                        if (action == SIG_DFL)
                                p->p_sig &= ~mask;
                        if (action == SIG_CATCH)
@@ -767,7 +769,7 @@ issig()
                         * If traced, always stop, and stay
                         * stopped until released by the parent.
                         */
                         * If traced, always stop, and stay
                         * stopped until released by the parent.
                         */
-                       p->p_cursig = sig;
+                       p->p_xstat = sig;
                        psignal(p->p_pptr, SIGCHLD);
                        do {
                                stop(p);
                        psignal(p->p_pptr, SIGCHLD);
                        do {
                                stop(p);
@@ -784,11 +786,11 @@ issig()
 
                        /*
                         * If parent wants us to take the signal,
 
                        /*
                         * If parent wants us to take the signal,
-                        * then it will leave it in p->p_cursig;
+                        * then it will leave it in p->p_xstat;
                         * otherwise we just look for signals again.
                         */
                        p->p_sig &= ~mask;      /* clear the old signal */
                         * otherwise we just look for signals again.
                         */
                        p->p_sig &= ~mask;      /* clear the old signal */
-                       sig = p->p_cursig;
+                       sig = p->p_xstat;
                        if (sig == 0)
                                continue;
 
                        if (sig == 0)
                                continue;
 
@@ -828,7 +830,7 @@ issig()
                                    (p->p_pgrp->pg_jobc == 0 &&
                                    mask & ttystopsigmask))
                                        break;  /* == ignore */
                                    (p->p_pgrp->pg_jobc == 0 &&
                                    mask & ttystopsigmask))
                                        break;  /* == ignore */
-                               p->p_cursig = sig;
+                               p->p_xstat = sig;
                                stop(p);
                                if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
                                        psignal(p->p_pptr, SIGCHLD);
                                stop(p);
                                if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
                                        psignal(p->p_pptr, SIGCHLD);
@@ -912,7 +914,6 @@ psig(sig)
                        if (action == SIG_IGN || (p->p_sigmask & mask))
                                panic("psig action");
 #endif
                        if (action == SIG_IGN || (p->p_sigmask & mask))
                                panic("psig action");
 #endif
-                       u.u_error = 0;
                        /*
                         * Set the new mask value and also defer further
                         * occurences of this signal.
                        /*
                         * Set the new mask value and also defer further
                         * occurences of this signal.
@@ -946,7 +947,7 @@ psig(sig)
                case SIGFPE:
                case SIGSEGV:
                case SIGSYS:
                case SIGFPE:
                case SIGSEGV:
                case SIGSYS:
-                       u.u_arg[0] = sig;
+                       u.u_sig = sig;
                        if (core() == 0)
                                sig |= WCOREFLAG;
                }
                        if (core() == 0)
                                sig |= WCOREFLAG;
                }
@@ -1042,5 +1043,5 @@ nosys(p, args, retval)
 {
 
        psignal(p, SIGSYS);
 {
 
        psignal(p, SIGSYS);
-       RETURN (EINVAL);
+       return (EINVAL);
 }
 }