delete unneeded header files
[unix-history] / usr / src / sys / kern / kern_sig.c
index 749e330..82d2aba 100644 (file)
@@ -1,8 +1,15 @@
-/*     kern_sig.c      6.13    85/03/13        */
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ *     @(#)kern_sig.c  7.3 (Berkeley) %G%
+ */
 
 #include "../machine/reg.h"
 #include "../machine/pte.h"
 #include "../machine/psl.h"
 
 #include "../machine/reg.h"
 #include "../machine/pte.h"
 #include "../machine/psl.h"
+#include "../machine/mtpr.h"
 
 #include "param.h"
 #include "systm.h"
 
 #include "param.h"
 #include "systm.h"
@@ -12,7 +19,6 @@
 #include "proc.h"
 #include "timeb.h"
 #include "times.h"
 #include "proc.h"
 #include "timeb.h"
 #include "times.h"
-#include "conf.h"
 #include "buf.h"
 #include "mount.h"
 #include "text.h"
 #include "buf.h"
 #include "mount.h"
 #include "text.h"
@@ -23,6 +29,8 @@
 #include "kernel.h"
 
 #define        cantmask        (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP))
 #include "kernel.h"
 
 #define        cantmask        (sigmask(SIGKILL)|sigmask(SIGCONT)|sigmask(SIGSTOP))
+#define        stopsigmask     (sigmask(SIGSTOP)|sigmask(SIGTSTP)| \
+                       sigmask(SIGTTIN)|sigmask(SIGTTOU))
 
 /*
  * Generalized interface signal handler.
 
 /*
  * Generalized interface signal handler.
@@ -207,8 +215,7 @@ kill()
        }
        switch (uap->pid) {
        case -1:                /* broadcast signal */
        }
        switch (uap->pid) {
        case -1:                /* broadcast signal */
-               if (suser())
-                       u.u_error = killpg1(uap->signo, 0, 1);
+               u.u_error = killpg1(uap->signo, 0, 1);
                break;
        case 0:                 /* signal own process group */
                u.u_error = killpg1(uap->signo, 0, 0);
                break;
        case 0:                 /* signal own process group */
                u.u_error = killpg1(uap->signo, 0, 0);
@@ -248,22 +255,23 @@ killpg1(signo, pgrp, all)
                 */
                pgrp = u.u_procp->p_pgrp;
                if (pgrp == 0)
                 */
                pgrp = u.u_procp->p_pgrp;
                if (pgrp == 0)
-                       return (EINVAL);
+                       return (ESRCH);
        }
        for (f = 0, p = allproc; p != NULL; p = p->p_nxt) {
                if ((p->p_pgrp != pgrp && !all) || p->p_ppid == 0 ||
                    (p->p_flag&SSYS) || (all && p == u.u_procp))
                        continue;
        }
        for (f = 0, p = allproc; p != NULL; p = p->p_nxt) {
                if ((p->p_pgrp != pgrp && !all) || p->p_ppid == 0 ||
                    (p->p_flag&SSYS) || (all && p == u.u_procp))
                        continue;
-               f++;
                if (u.u_uid != 0 && u.u_uid != p->p_uid &&
                    (signo != SIGCONT || !inferior(p))) {
                if (u.u_uid != 0 && u.u_uid != p->p_uid &&
                    (signo != SIGCONT || !inferior(p))) {
-                       error = EPERM;
+                       if (!all)
+                               error = EPERM;
                        continue;
                }
                        continue;
                }
+               f++;
                if (signo)
                        psignal(p, signo);
        }
                if (signo)
                        psignal(p, signo);
        }
-       return (f == 0 ? ESRCH : error);
+       return (error ? error : (f == 0 ? ESRCH : 0));
 }
 
 /*
 }
 
 /*
@@ -318,8 +326,6 @@ psignal(p, sig)
                else
                        action = SIG_DFL;
        }
                else
                        action = SIG_DFL;
        }
-#define        stops   (sigmask(SIGSTOP)|sigmask(SIGTSTP)| \
-                       sigmask(SIGTTIN)|sigmask(SIGTTOU))
        if (sig) {
                p->p_sig |= mask;
                switch (sig) {
        if (sig) {
                p->p_sig |= mask;
                switch (sig) {
@@ -335,7 +341,7 @@ psignal(p, sig)
                        break;
 
                case SIGCONT:
                        break;
 
                case SIGCONT:
-                       p->p_sig &= ~stops;
+                       p->p_sig &= ~stopsigmask;
                        break;
 
                case SIGSTOP:
                        break;
 
                case SIGSTOP:
@@ -346,7 +352,6 @@ psignal(p, sig)
                        break;
                }
        }
                        break;
                }
        }
-#undef stops
        /*
         * Defer further processing for signals which are held.
         */
        /*
         * Defer further processing for signals which are held.
         */
@@ -486,7 +491,6 @@ psignal(p, sig)
                 * It will either never be noticed, or noticed very soon.
                 */
                if (p == u.u_procp && !noproc)
                 * It will either never be noticed, or noticed very soon.
                 */
                if (p == u.u_procp && !noproc)
-#include "../vax/mtpr.h"
                        aston();
                goto out;
        }
                        aston();
                goto out;
        }
@@ -526,11 +530,10 @@ issig()
                if ((p->p_flag&STRC) == 0)
                        sigbits &= ~p->p_sigignore;
                if (p->p_flag&SVFORK)
                if ((p->p_flag&STRC) == 0)
                        sigbits &= ~p->p_sigignore;
                if (p->p_flag&SVFORK)
-#define bit(a) (1<<(a-1))
-                       sigbits &= ~(bit(SIGSTOP)|bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU));
+                       sigbits &= ~stopsigmask;
                if (sigbits == 0)
                        break;
                if (sigbits == 0)
                        break;
-               sig = ffs(sigbits);
+               sig = ffs((long)sigbits);
                mask = sigmask(sig);
                p->p_sig &= ~mask;              /* take the signal! */
                p->p_cursig = sig;
                mask = sigmask(sig);
                p->p_sig &= ~mask;              /* take the signal! */
                p->p_cursig = sig;
@@ -575,7 +578,7 @@ issig()
                                continue;
                        }
                }
                                continue;
                        }
                }
-               switch (u.u_signal[sig]) {
+               switch ((int)u.u_signal[sig]) {
 
                case SIG_DFL:
                        /*
 
                case SIG_DFL:
                        /*
@@ -761,6 +764,8 @@ core()
        if (ctob(UPAGES+u.u_dsize+u.u_ssize) >=
            u.u_rlimit[RLIMIT_CORE].rlim_cur)
                return (0);
        if (ctob(UPAGES+u.u_dsize+u.u_ssize) >=
            u.u_rlimit[RLIMIT_CORE].rlim_cur)
                return (0);
+       if (u.u_procp->p_textp && access(u.u_procp->p_textp->x_iptr, IREAD))
+               return (0);
        u.u_error = 0;
        ndp->ni_nameiop = CREATE | FOLLOW;
        ndp->ni_segflg = UIO_SYSSPACE;
        u.u_error = 0;
        ndp->ni_nameiop = CREATE | FOLLOW;
        ndp->ni_segflg = UIO_SYSSPACE;
@@ -779,22 +784,30 @@ core()
                u.u_error = EFAULT;
                goto out;
        }
                u.u_error = EFAULT;
                goto out;
        }
+#ifdef MMAP
+       { register int fd;
+       /* unmasp funky devices in the user's address space */
+       for (fd = 0; fd < u.u_lastfile; fd++)
+               if (u.u_ofile[fd] && (u.u_pofile[fd] & UF_MAPPED))
+                       munmapfd(fd);
+       }
+#endif
        itrunc(ip, (u_long)0);
        u.u_acflag |= ACORE;
        u.u_error = rdwri(UIO_WRITE, ip,
            (caddr_t)&u,
            ctob(UPAGES),
        itrunc(ip, (u_long)0);
        u.u_acflag |= ACORE;
        u.u_error = rdwri(UIO_WRITE, ip,
            (caddr_t)&u,
            ctob(UPAGES),
-           0, 1, (int *)0);
+           (off_t)0, 1, (int *)0);
        if (u.u_error == 0)
                u.u_error = rdwri(UIO_WRITE, ip,
                    (caddr_t)ctob(dptov(u.u_procp, 0)),
        if (u.u_error == 0)
                u.u_error = rdwri(UIO_WRITE, ip,
                    (caddr_t)ctob(dptov(u.u_procp, 0)),
-                   ctob(u.u_dsize),
-                   ctob(UPAGES), 0, (int *)0);
+                   (int)ctob(u.u_dsize),
+                   (off_t)ctob(UPAGES), 0, (int *)0);
        if (u.u_error == 0)
                u.u_error = rdwri(UIO_WRITE, ip,
                    (caddr_t)ctob(sptov(u.u_procp, u.u_ssize - 1)),
        if (u.u_error == 0)
                u.u_error = rdwri(UIO_WRITE, ip,
                    (caddr_t)ctob(sptov(u.u_procp, u.u_ssize - 1)),
-                   ctob(u.u_ssize),
-                   ctob(UPAGES)+ctob(u.u_dsize), 0, (int *)0);
+                   (int)ctob(u.u_ssize),
+                   (off_t)ctob(UPAGES)+ctob(u.u_dsize), 0, (int *)0);
 out:
        iput(ip);
        return (u.u_error == 0);
 out:
        iput(ip);
        return (u.u_error == 0);