]> granicus.if.org Git - procps-ng/commitdiff
skill: fix argument parsing regression
authorSami Kerola <kerolasa@iki.fi>
Thu, 9 Feb 2012 21:53:29 +0000 (22:53 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 11 Feb 2012 20:42:35 +0000 (21:42 +0100)
Command skill accepted earlier command name as argument.  This did
not work since commit 991b8a94f0354a128085c7411713e17282c4e04a.

Reported-By: "Anne C. Hanna" <orion@ugcs.caltech.edu>
Bug-Debian: http://bugs.debian.org/659038
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
skill.c

diff --git a/skill.c b/skill.c
index 68025424151e5f56b07e2f6cad8bc41644fe9261..0ea21ca4d6f078e9d6b4e5626f8b7d37994fb5aa 100644 (file)
--- a/skill.c
+++ b/skill.c
@@ -594,9 +594,16 @@ static void skillsnice_parse(int argc,
        argv += optind;
 
        for (i = 0; i < argc; i++) {
-               ENLIST(pid, strtol_or_err(argv[0],
-                                         _("failed to parse argument")));
-               pid_count++;
+               long num;
+               char *end = NULL;
+               errno = 0;
+               num = strtol(argv[0], &end, 10);
+               if (errno == 0 && argv[0] != end && end != NULL && *end == '\0') {
+                       ENLIST(pid, num);
+                       pid_count++;
+               } else {
+                       ENLIST(cmd, argv[0]);
+               }
                argv++;
        }