Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-09-21 00:24:33 +0400
committerChristopher Faylor <me@cgf.cx>2003-09-21 00:24:33 +0400
commit7ed1b504b6411ca1d27009e73bde7f053dbf65fd (patch)
tree37833ba89e48b6d0dbdf0a4a7914e748c70b0dd4 /winsup/utils/kill.cc
parent0199487e6a7933f9a6757c77a409c6a8b271d1d3 (diff)
* kill.cc (main): Allow negative pids (indicates process groups).
Diffstat (limited to 'winsup/utils/kill.cc')
-rw-r--r--winsup/utils/kill.cc17
1 files changed, 14 insertions, 3 deletions
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;
}