BSD 4_4_Lite1 release
[unix-history] / usr / src / sys / kern / kern_sig.c
index 8561edb..3dcff92 100644 (file)
@@ -7,9 +7,35 @@
  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  * the permission of UNIX System Laboratories, Inc.
  *
  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  * the permission of UNIX System Laboratories, Inc.
  *
- * %sccs.include.redist.c%
+ * 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.
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. 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.
  *
  *
- *     @(#)kern_sig.c  8.5 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ *     @(#)kern_sig.c  8.7 (Berkeley) 4/18/94
  */
 
 #define        SIGPROP         /* include signal properties table */
  */
 
 #define        SIGPROP         /* include signal properties table */
@@ -998,7 +1024,7 @@ postsig(signum)
        register struct proc *p = curproc;
        register struct sigacts *ps = p->p_sigacts;
        register sig_t action;
        register struct proc *p = curproc;
        register struct sigacts *ps = p->p_sigacts;
        register sig_t action;
-       int mask, returnmask;
+       int code, mask, returnmask;
 
 #ifdef DIAGNOSTIC
        if (signum == 0)
 
 #ifdef DIAGNOSTIC
        if (signum == 0)
@@ -1046,7 +1072,13 @@ postsig(signum)
                p->p_sigmask |= ps->ps_catchmask[signum] | mask;
                (void) spl0();
                p->p_stats->p_ru.ru_nsignals++;
                p->p_sigmask |= ps->ps_catchmask[signum] | mask;
                (void) spl0();
                p->p_stats->p_ru.ru_nsignals++;
-               sendsig(action, signum, returnmask, 0);
+               if (ps->ps_sig != signum) {
+                       code = 0;
+               } else {
+                       code = ps->ps_code;
+                       ps->ps_code = 0;
+               }
+               sendsig(action, signum, returnmask, code);
        }
 }
 
        }
 }
 
@@ -1087,8 +1119,8 @@ sigexit(p, signum)
 }
 
 /*
 }
 
 /*
- * Dump core, into a file named "core.progname".
- * Do not drop core if the process was setuid/setgid.
+ * Dump core, into a file named "progname.core", unless the process was
+ * setuid/setgid.
  */
 coredump(p)
        register struct proc *p;
  */
 coredump(p)
        register struct proc *p;
@@ -1097,9 +1129,9 @@ coredump(p)
        register struct pcred *pcred = p->p_cred;
        register struct ucred *cred = pcred->pc_ucred;
        register struct vmspace *vm = p->p_vmspace;
        register struct pcred *pcred = p->p_cred;
        register struct ucred *cred = pcred->pc_ucred;
        register struct vmspace *vm = p->p_vmspace;
+       struct nameidata nd;
        struct vattr vattr;
        int error, error1;
        struct vattr vattr;
        int error, error1;
-       struct nameidata nd;
        char name[MAXCOMLEN+6];         /* progname.core */
 
        if (pcred->p_svuid != pcred->p_ruid || pcred->p_svgid != pcred->p_rgid)
        char name[MAXCOMLEN+6];         /* progname.core */
 
        if (pcred->p_svuid != pcred->p_ruid || pcred->p_svgid != pcred->p_rgid)