Signal names from libc; /bin/kill compatible builtin
authorChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Mon, 5 Aug 1991 08:36:32 +0000 (00:36 -0800)
committerChristos Zoulas <christos@ucbvax.Berkeley.EDU>
Mon, 5 Aug 1991 08:36:32 +0000 (00:36 -0800)
SCCS-vsn: bin/csh/csh.h 5.18
SCCS-vsn: bin/csh/init.c 5.15
SCCS-vsn: bin/csh/proc.c 5.25

usr/src/bin/csh/csh.h
usr/src/bin/csh/init.c
usr/src/bin/csh/proc.c

index e57c1e6..bcf9da8 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)csh.h       5.17 (Berkeley) %G%
+ *     @(#)csh.h       5.18 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -491,11 +491,6 @@ char  **Vt;
 Char  **evalvec;
 Char   *evalp;
 
 Char  **evalvec;
 Char   *evalp;
 
-extern struct mesg {
-    char   *iname;             /* name from /usr/include */
-    char   *pname;             /* print name */
-}       mesg[];
-
 /* word_chars is set by default to WORD_CHARS but can be overridden by
    the worchars variable--if unset, reverts to WORD_CHARS */
 
 /* word_chars is set by default to WORD_CHARS but can be overridden by
    the worchars variable--if unset, reverts to WORD_CHARS */
 
index 369f98e..fd0ba05 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)init.c     5.14 (Berkeley) %G%";
+static char sccsid[] = "@(#)init.c     5.15 (Berkeley) %G%";
 #endif /* not lint */
 
 #if __STDC__
 #endif /* not lint */
 
 #if __STDC__
@@ -106,39 +106,3 @@ struct srch srchn[] =
 };
 int     nsrchn = sizeof srchn / sizeof *srchn;
 
 };
 int     nsrchn = sizeof srchn / sizeof *srchn;
 
-struct mesg mesg[] =
-{
-     /*  0 */  0,              "",
-     /*  1 */  "HUP",          "Hangup",
-     /*  2 */  "INT",          "Interrupt",
-     /*  3 */  "QUIT",         "Quit",
-     /*  4 */  "ILL",          "Illegal instruction",
-     /*  5 */  "TRAP",         "Trace/BPT trap",
-     /*  6 */  "IOT",          "IOT trap",
-     /*  7 */  "EMT",          "EMT trap",
-     /*  8 */  "FPE",          "Floating exception",
-     /*  9 */  "KILL",         "Killed",
-     /* 10 */  "BUS",          "Bus error",
-     /* 11 */  "SEGV",         "Segmentation fault",
-     /* 12 */  "SYS",          "Bad system call",
-     /* 13 */  "PIPE",         "Broken pipe",
-     /* 14 */  "ALRM",         "Alarm clock",
-     /* 15 */  "TERM",         "Terminated",
-     /* 16 */  "URG",          "Urgent condition on IO channel",
-     /* 17 */  "STOP",         "Suspended (signal)",
-     /* 18 */  "TSTP",         "Suspended",
-     /* 19 */  "CONT",         "Continued",
-     /* 20 */  "CHLD",         "Child exited",
-     /* 21 */  "TTIN",         "Suspended (tty input)",
-     /* 22 */  "TTOU",         "Suspended (tty output)",
-     /* 23 */  "IO",           "IO possible interrupt",
-     /* 24 */  "XCPU",         "Cputime limit exceeded",
-     /* 25 */  "XFSZ",         "Filesize limit exceeded",
-     /* 26 */  "VTALRM",       "Virtual time alarm",
-     /* 27 */  "PROF",         "Profiling time alarm",
-     /* 28 */  "WINCH",        "Window changed",
-     /* 29 */  "INFO",         "Information request",
-     /* 30 */  "USR1",         "User signal 1",
-     /* 31 */  "USR2",         "User signal 2",
-     /* 32 */  0,              "Signal 32",
-};
index 4c03f40..43cbb56 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)proc.c     5.24 (Berkeley) %G%";
+static char sccsid[] = "@(#)proc.c     5.25 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -705,7 +705,7 @@ pprint(pp, flag)
                             && (reason != SIGPIPE
                                 || (pp->p_flags & PPOU) == 0))) {
                        (void) fprintf(cshout, format, 
                             && (reason != SIGPIPE
                                 || (pp->p_flags & PPOU) == 0))) {
                        (void) fprintf(cshout, format, 
-                                      mesg[pp->p_reason].pname);
+                                      sys_signame[pp->p_reason]);
                        hadnl = 0;
                    }
                    break;
                        hadnl = 0;
                    }
                    break;
@@ -925,21 +925,16 @@ dokill(v, t)
     Char **v;
     struct command *t;
 {
     Char **v;
     struct command *t;
 {
-    register int signum, len = 0;
+    register int signum = SIGTERM;
     register char *name;
 
     v++;
     if (v[0] && v[0][0] == '-') {
        if (v[0][1] == 'l') {
     register char *name;
 
     v++;
     if (v[0] && v[0][0] == '-') {
        if (v[0][1] == 'l') {
-           for (signum = 1; signum <= NSIG; signum++) {
-               if ((name = mesg[signum].iname) != NULL) {
-                   len += strlen(name) + 1;
-                   if (len >= 80 - 1) {
-                       (void) fputc('\n', cshout);
-                       len = strlen(name) + 1;
-                   }
-                   (void) fprintf(cshout, "%s ", name);
-               }
+           for (signum = 1; signum < NSIG; signum++) {
+               (void) fprintf(cshout, "%s ", sys_signame[signum]);
+               if (signum == NSIG / 2)
+                   (void) fputc('\n', cshout);
            }
            (void) fputc('\n', cshout);
            return;
            }
            (void) fputc('\n', cshout);
            return;
@@ -950,18 +945,21 @@ dokill(v, t)
                stderror(ERR_NAME | ERR_BADSIG);
        }
        else {
                stderror(ERR_NAME | ERR_BADSIG);
        }
        else {
-           for (signum = 1; signum <= NSIG; signum++)
-               if (mesg[signum].iname &&
-                   eq(&v[0][1], str2short(mesg[signum].iname)))
-                   goto gotsig;
-           setname(short2str(&v[0][1]));
-           stderror(ERR_NAME | ERR_UNKSIG);
+           name = short2str(&v[0][1]);
+           if (!strncasecmp(name, "sig", 3))
+               name += 3;
+
+           for (signum = 1; signum < NSIG; signum++) 
+               if (!strcasecmp(sys_signame[signum], name))
+                   break;
+
+           if (signum == NSIG) {
+               setname(short2str(&v[0][1]));
+               stderror(ERR_NAME | ERR_UNKSIG);
+           }
        }
        }
-gotsig:
        v++;
     }
        v++;
     }
-    else
-       signum = SIGTERM;
     pkill(v, signum);
 }
 
     pkill(v, signum);
 }