Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/pkill add -l support to prenice, as noted by enami.



details:   https://anonhg.NetBSD.org/src/rev/a10114f7d171
branches:  trunk
changeset: 759365:a10114f7d171
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Dec 07 07:39:15 2010 +0000

description:
add -l support to prenice, as noted by enami.

diffstat:

 usr.bin/pkill/pkill.1 |   7 +++++--
 usr.bin/pkill/pkill.c |  46 +++++++++++++++++++++++++++++-----------------
 2 files changed, 34 insertions(+), 19 deletions(-)

diffs (119 lines):

diff -r 469b09d8e9a5 -r a10114f7d171 usr.bin/pkill/pkill.1
--- a/usr.bin/pkill/pkill.1     Tue Dec 07 05:51:45 2010 +0000
+++ b/usr.bin/pkill/pkill.1     Tue Dec 07 07:39:15 2010 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: pkill.1,v 1.20 2010/12/06 08:34:28 wiz Exp $
+.\"    $NetBSD: pkill.1,v 1.21 2010/12/07 07:39:15 mrg Exp $
 .\"
 .\" Copyright (c) 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -57,6 +57,7 @@
 .Op Fl u Ar euid
 .Op Ar pattern ...
 .Nm prenice
+.Op Fl l
 .Op Ar priority
 .Op Ar pattern ...
 .Sh DESCRIPTION
@@ -79,7 +80,9 @@
 The following options are available for
 .Nm pkill
 and
-.Nm pgrep :
+.Nm pgrep ,
+and some are available for
+.Nm prenice :
 .Bl -tag -width xxxxxxxx
 .It Fl d Ar delim
 Specify a delimiter to be printed between each process ID.
diff -r 469b09d8e9a5 -r a10114f7d171 usr.bin/pkill/pkill.c
--- a/usr.bin/pkill/pkill.c     Tue Dec 07 05:51:45 2010 +0000
+++ b/usr.bin/pkill/pkill.c     Tue Dec 07 07:39:15 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pkill.c,v 1.26 2010/12/06 04:00:11 mrg Exp $   */
+/*     $NetBSD: pkill.c,v 1.27 2010/12/07 07:39:15 mrg Exp $   */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: pkill.c,v 1.26 2010/12/06 04:00:11 mrg Exp $");
+__RCSID("$NetBSD: pkill.c,v 1.27 2010/12/07 07:39:15 mrg Exp $");
 #endif /* !lint */
 
 #include <sys/types.h>
@@ -129,18 +129,7 @@
                pgrep = 1;
        } else if (strcmp(getprogname(), "prenice") == 0) {
                prenice = 1;
-               if (argc < 2)
-                       usage();
-               action = reniceact;
-               p = argv[1];
 
-               i = (int)strtol(p, &q, 10);
-               if (*q == '\0') {
-                       nicenum = i;
-                       argv++;
-                       argc--;
-               } else
-                       usage();
        } else {
                action = killact;
                p = argv[1];
@@ -169,7 +158,30 @@
 
        criteria = 0;
 
-       if (!prenice) {
+       if (prenice) {
+               if (argc < 2)
+                       usage();
+
+               if (strcmp(argv[1], "-l") == 0) {
+                       longfmt = 1;
+                       argv++;
+                       argc--;
+               }
+
+               if (argc < 2)
+                       usage();
+
+               action = reniceact;
+               p = argv[1];
+
+               i = (int)strtol(p, &q, 10);
+               if (*q == '\0') {
+                       nicenum = i;
+                       argv++;
+                       argc--;
+               } else
+                       usage();
+       } else {
                while ((ch = getopt(argc, argv, "G:P:U:d:fg:ilns:t:u:vx")) != -1)
                        switch (ch) {
                        case 'G':
@@ -228,10 +240,10 @@
                                usage();
                                /* NOTREACHED */
                        }
+               argc -= optind;
+               argv += optind;
        }
 
-       argc -= optind;
-       argv += optind;
        if (argc != 0)
                criteria = 1;
        if (!criteria)
@@ -427,7 +439,7 @@
        const char *ustr;
 
        if (prenice)
-               fprintf(stderr, "Usage: %s priority pattern ...\n",
+               fprintf(stderr, "Usage: %s [-l] priority pattern ...\n",
                    getprogname());
        else {
                if (pgrep)



Home | Main Index | Thread Index | Old Index