If a process exists but has a different uid than the killer it should return
[unix-history] / usr / src / sys / kern / kern_sig.c
index f44e4c8..07a8467 100644 (file)
@@ -1,4 +1,4 @@
-/*     kern_sig.c      5.22    83/06/21        */
+/*     kern_sig.c      6.2     83/09/08        */
 
 #include "../machine/reg.h"
 #include "../machine/pte.h"
 
 #include "../machine/reg.h"
 #include "../machine/pte.h"
@@ -151,7 +151,6 @@ sigpause()
 sigstack()
 {
        register struct a {
 sigstack()
 {
        register struct a {
-               caddr_t asp;
                struct  sigstack *nss;
                struct  sigstack *oss;
        } *uap = (struct a *)u.u_ap;
                struct  sigstack *nss;
                struct  sigstack *oss;
        } *uap = (struct a *)u.u_ap;
@@ -206,8 +205,10 @@ kill1(ispgrp, signo, who)
                return (EINVAL);
        if (who > 0 && !ispgrp) {
                p = pfind(who);
                return (EINVAL);
        if (who > 0 && !ispgrp) {
                p = pfind(who);
-               if (p == 0 || u.u_uid && u.u_uid != p->p_uid)
+               if (p == 0)
                        return (ESRCH);
                        return (ESRCH);
+               if (u.u_uid && u.u_uid != p->p_uid)
+                       return (EPERM);
                if (signo)
                        psignal(p, signo);
                return (0);
                if (signo)
                        psignal(p, signo);
                return (0);
@@ -503,9 +504,9 @@ issig()
 
        p = u.u_procp;
        for (;;) {
 
        p = u.u_procp;
        for (;;) {
-               sigbits = p->p_sig;
+               sigbits = p->p_sig &~ p->p_sigmask;
                if ((p->p_flag&STRC) == 0)
                if ((p->p_flag&STRC) == 0)
-                       sigbits &= ~(p->p_sigignore | p->p_sigmask);
+                       sigbits &= ~p->p_sigignore;
                if (p->p_flag&SVFORK)
 #define bit(a) (1<<(a-1))
                        sigbits &= ~(bit(SIGSTOP)|bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU));
                if (p->p_flag&SVFORK)
 #define bit(a) (1<<(a-1))
                        sigbits &= ~(bit(SIGSTOP)|bit(SIGTSTP)|bit(SIGTTIN)|bit(SIGTTOU));
@@ -526,13 +527,12 @@ issig()
                        } while (!procxmt() && p->p_flag&STRC);
 
                        /*
                        } while (!procxmt() && p->p_flag&STRC);
 
                        /*
-                        * If the traced bit got turned off or signal
-                        * is being masked, then put the signal taken
-                        * above back into p_sig and go back up to the
-                        * top to rescan signals.  This ensures that
-                        * p_sig* and u_signal are consistent.
+                        * If the traced bit got turned off,
+                        * then put the signal taken above back into p_sig
+                        * and go back up to the top to rescan signals.
+                        * This ensures that p_sig* and u_signal are consistent.
                         */
                         */
-                       if ((p->p_flag&STRC) == 0 || (p->p_sigmask & sigmask)) {
+                       if ((p->p_flag&STRC) == 0) {
                                p->p_sig |= sigmask;
                                continue;
                        }
                                p->p_sig |= sigmask;
                                continue;
                        }
@@ -545,6 +545,16 @@ issig()
                        sig = p->p_cursig;
                        if (sig == 0)
                                continue;
                        sig = p->p_cursig;
                        if (sig == 0)
                                continue;
+
+                       /*
+                        * If signal is being masked put it back
+                        * into p_sig and look for other signals.
+                        */
+                       sigmask = 1 << (sig-1);
+                       if (p->p_sigmask & sigmask) {
+                               p->p_sig |= sigmask;
+                               continue;
+                       }
                }
                switch (u.u_signal[sig]) {
 
                }
                switch (u.u_signal[sig]) {