* kill.cc (main): Allow negative pids (indicates process groups).

This commit is contained in:
Christopher Faylor 2003-09-20 20:24:33 +00:00
parent 0199487e6a
commit 7ed1b504b6
2 changed files with 18 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2003-09-20 Christopher Faylor <cgf@redhat.com>
* kill.cc (main): Allow negative pids (indicates process groups).
2003-09-17 Christopher Faylor <cgf@redhat.com> 2003-09-17 Christopher Faylor <cgf@redhat.com>
* parse_pe.cc (exclusion::sort_and_check): Make error message a little * parse_pe.cc (exclusion::sort_and_check): Make error message a little

View File

@ -164,6 +164,10 @@ main (int argc, char **argv)
usage (); usage ();
opterr = 0; opterr = 0;
char *p;
int pid = 0;
for (;;) for (;;)
{ {
int ch; int ch;
@ -201,7 +205,12 @@ main (int argc, char **argv)
break; break;
case '?': case '?':
if (gotasig) if (gotasig)
{
pid = strtol (argv[optind], &p, 10);
if (pid < 0)
goto out;
usage (); usage ();
}
optreset = 1; optreset = 1;
optind = 1 + av - argv; optind = 1 + av - argv;
gotasig = *av + 1; gotasig = *av + 1;
@ -213,13 +222,14 @@ main (int argc, char **argv)
} }
} }
out:
test_for_unknown_sig (sig, gotasig); test_for_unknown_sig (sig, gotasig);
argv += optind; argv += optind;
while (*argv != NULL) while (*argv != NULL)
{ {
char *p; if (!pid)
int pid = strtol (*argv, &p, 10); pid = strtol (*argv, &p, 10);
if (*p != '\0') if (*p != '\0')
{ {
fprintf (stderr, "%s: illegal pid: %s\n", prog_name, *argv); fprintf (stderr, "%s: illegal pid: %s\n", prog_name, *argv);
@ -240,6 +250,7 @@ main (int argc, char **argv)
ret = 1; ret = 1;
} }
argv++; argv++;
pid = 0;
} }
return ret; return ret;
} }