make it look like kernel driver
[unix-history] / usr / src / bin / csh / proc.c
index 62d27f1..e0c9aa5 100644 (file)
@@ -1,5 +1,11 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley Software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)proc.c      4.16 (Berkeley) %G%";
+static char *sccsid = "@(#)proc.c      5.5 (Berkeley) %G%";
 #endif
 
 #include "sh.h"
 #endif
 
 #include "sh.h"
@@ -202,7 +208,7 @@ pjwait(pp)
                while ((fp = (fp->p_friends)) != pp);
                if ((jobflags & PRUNNING) == 0)
                        break;
                while ((fp = (fp->p_friends)) != pp);
                if ((jobflags & PRUNNING) == 0)
                        break;
-               sigpause(0);
+               sigpause(sigblock(0) &~ sigmask(SIGCHLD));
        }
        (void) sigsetmask(omask);
        if (tpgrp > 0)                  /* get tty back */
        }
        (void) sigsetmask(omask);
        if (tpgrp > 0)                  /* get tty back */
@@ -579,8 +585,9 @@ pprint(pp, flag)
                                case PINTERRUPTED:
                                case PSTOPPED:
                                case PSIGNALED:
                                case PINTERRUPTED:
                                case PSTOPPED:
                                case PSIGNALED:
-                                       if (flag&REASON || reason != SIGINT ||
-                                           reason != SIGPIPE)
+                                       if ((flag&(REASON|AREASON))
+                                           && reason != SIGINT
+                                           && reason != SIGPIPE)
                                                printf(format, mesg[pp->p_reason].pname);
                                        break;
 
                                                printf(format, mesg[pp->p_reason].pname);
                                        break;
 
@@ -783,7 +790,7 @@ dokill(v)
                }
                if (digit(v[0][1])) {
                        signum = atoi(v[0]+1);
                }
                if (digit(v[0][1])) {
                        signum = atoi(v[0]+1);
-                       if (signum < 1 || signum > NSIG)
+                       if (signum < 0 || signum > NSIG)
                                bferr("Bad signal number");
                } else {
                        name = &v[0][1];
                                bferr("Bad signal number");
                } else {
                        name = &v[0][1];
@@ -834,10 +841,14 @@ pkill(v, signum)
                                        goto cont;
                                }
                        }
                                        goto cont;
                                }
                        }
-                       (void) killpg(pp->p_jobid, signum);
+                       if (killpg(pp->p_jobid, signum) < 0) {
+                               printf("%s: ", cp);
+                               printf("%s\n", sys_errlist[errno]);
+                               err++;
+                       }
                        if (signum == SIGTERM || signum == SIGHUP)
                                (void) killpg(pp->p_jobid, SIGCONT);
                        if (signum == SIGTERM || signum == SIGHUP)
                                (void) killpg(pp->p_jobid, SIGCONT);
-               } else if (!digit(*cp))
+               } else if (!(digit(*cp) || *cp == '-'))
                        bferr("Arguments should be jobs or process id's");
                else {
                        pid = atoi(cp);
                        bferr("Arguments should be jobs or process id's");
                else {
                        pid = atoi(cp);