summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-09-20 20:24:33 +0000
committerChristopher Faylor <me@cgf.cx>2003-09-20 20:24:33 +0000
commit7ed1b504b6411ca1d27009e73bde7f053dbf65fd (patch)
tree37833ba89e48b6d0dbdf0a4a7914e748c70b0dd4
parent0199487e6a7933f9a6757c77a409c6a8b271d1d3 (diff)
downloadcygnal-7ed1b504b6411ca1d27009e73bde7f053dbf65fd.tar.gz
cygnal-7ed1b504b6411ca1d27009e73bde7f053dbf65fd.tar.bz2
cygnal-7ed1b504b6411ca1d27009e73bde7f053dbf65fd.zip
* kill.cc (main): Allow negative pids (indicates process groups).
-rw-r--r--winsup/utils/ChangeLog4
-rw-r--r--winsup/utils/kill.cc17
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 <cgf@redhat.com>
+
+ * kill.cc (main): Allow negative pids (indicates process groups).
+
2003-09-17 Christopher Faylor <cgf@redhat.com>
* 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;
}