add 1994 copyright
[unix-history] / usr / src / bin / kill / kill.c
index 6e4ba11..7d7307d 100644 (file)
@@ -1,37 +1,39 @@
 /*
 /*
- * Copyright (c) 1988 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1988, 1993, 1994
+ *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
  *
  * %sccs.include.redist.c%
  */
 
 #ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1988 Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1988, 1993, 1994\n\
      The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)kill.c     5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)kill.c     8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
-#include <signal.h>
+#include <ctype.h>
+#include <err.h>
 #include <errno.h>
 #include <errno.h>
+#include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 
 void nosig __P((char *));
 void printsig __P((FILE *));
 void usage __P((void));
 
 
 void nosig __P((char *));
 void printsig __P((FILE *));
 void usage __P((void));
 
+int
 main(argc, argv)
        int argc;
 main(argc, argv)
        int argc;
-       char **argv;
+       char *argv[];
 {
 {
-       register int errors, numsig, pid;
-       register char **p;
+       const char *const *p;
+       int errors, numsig, pid;
        char *ep;
 
        if (argc < 2)
        char *ep;
 
        if (argc < 2)
@@ -57,11 +59,8 @@ main(argc, argv)
                                nosig(*argv);
                } else if (isdigit(**argv)) {
                        numsig = strtol(*argv, &ep, 10);
                                nosig(*argv);
                } else if (isdigit(**argv)) {
                        numsig = strtol(*argv, &ep, 10);
-                       if (!*argv || *ep) {
-                               (void)fprintf(stderr,
-                                   "kill: illegal signal number %s\n", *argv);
-                               exit(1);
-                       }
+                       if (!*argv || *ep)
+                               errx(1, "illegal signal number: %s", *argv);
                        if (numsig <= 0 || numsig > NSIG)
                                nosig(*argv);
                } else
                        if (numsig <= 0 || numsig > NSIG)
                                nosig(*argv);
                } else
@@ -75,13 +74,10 @@ main(argc, argv)
        for (errors = 0; *argv; ++argv) {
                pid = strtol(*argv, &ep, 10);
                if (!*argv || *ep) {
        for (errors = 0; *argv; ++argv) {
                pid = strtol(*argv, &ep, 10);
                if (!*argv || *ep) {
-                       (void)fprintf(stderr,
-                           "kill: illegal process id %s\n", *argv);
-                       continue;
-               }
-               if (kill(pid, numsig) == -1) {
-                       (void)fprintf(stderr,
-                           "kill: %s: %s\n", *argv, strerror(errno));
+                       warnx("illegal process id: %s", *argv);
+                       errors = 1;
+               } else if (kill(pid, numsig) == -1) {
+                       warn("%s", *argv);
                        errors = 1;
                }
        }
                        errors = 1;
                }
        }
@@ -92,8 +88,8 @@ void
 nosig(name)
        char *name;
 {
 nosig(name)
        char *name;
 {
-       (void)fprintf(stderr,
-           "kill: unknown signal %s; valid signals:\n", name);
+
+       warnx("unknown signal %s; valid signals:", name);
        printsig(stderr);
        exit(1);
 }
        printsig(stderr);
        exit(1);
 }
@@ -102,8 +98,8 @@ void
 printsig(fp)
        FILE *fp;
 {
 printsig(fp)
        FILE *fp;
 {
-       register int cnt;
-       register char **p;
+       const char *const *p;
+       int cnt;
 
        for (cnt = NSIG, p = sys_signame + 1; --cnt; ++p) {
                (void)fprintf(fp, "%s ", *p);
 
        for (cnt = NSIG, p = sys_signame + 1; --cnt; ++p) {
                (void)fprintf(fp, "%s ", *p);
@@ -116,6 +112,7 @@ printsig(fp)
 void
 usage()
 {
 void
 usage()
 {
+
        (void)fprintf(stderr, "usage: kill [-l] [-sig] pid ...\n");
        exit(1);
 }
        (void)fprintf(stderr, "usage: kill [-l] [-sig] pid ...\n");
        exit(1);
 }