From 7ed1b504b6411ca1d27009e73bde7f053dbf65fd Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 20 Sep 2003 20:24:33 +0000 Subject: [PATCH] * kill.cc (main): Allow negative pids (indicates process groups). --- winsup/utils/ChangeLog | 4 ++++ winsup/utils/kill.cc | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 62399be9a..819c5b16b 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,7 @@ +2003-09-20 Christopher Faylor + + * kill.cc (main): Allow negative pids (indicates process groups). + 2003-09-17 Christopher Faylor * parse_pe.cc (exclusion::sort_and_check): Make error message a little diff --git a/winsup/utils/kill.cc b/winsup/utils/kill.cc index 8067cf825..a4dba050d 100644 --- a/winsup/utils/kill.cc +++ b/winsup/utils/kill.cc @@ -164,6 +164,10 @@ main (int argc, char **argv) usage (); opterr = 0; + + char *p; + int pid = 0; + for (;;) { int ch; @@ -201,7 +205,12 @@ main (int argc, char **argv) break; case '?': if (gotasig) - usage (); + { + pid = strtol (argv[optind], &p, 10); + if (pid < 0) + goto out; + usage (); + } optreset = 1; optind = 1 + av - argv; gotasig = *av + 1; @@ -213,13 +222,14 @@ main (int argc, char **argv) } } +out: test_for_unknown_sig (sig, gotasig); argv += optind; while (*argv != NULL) { - char *p; - int pid = strtol (*argv, &p, 10); + if (!pid) + pid = strtol (*argv, &p, 10); if (*p != '\0') { fprintf (stderr, "%s: illegal pid: %s\n", prog_name, *argv); @@ -240,6 +250,7 @@ main (int argc, char **argv) ret = 1; } argv++; + pid = 0; } return ret; }