summaryrefslogtreecommitdiffstats
path: root/misc-utils/kill.c
diff options
context:
space:
mode:
authorKarel Zak2013-03-13 16:02:55 +0100
committerKarel Zak2013-03-13 16:02:55 +0100
commitf546276e2272c5e026f6a2ff667e50bca09d0ee7 (patch)
treea9e30fa7cf1d56c23e9ca9b27fb1179d49fd02c5 /misc-utils/kill.c
parentkill: add pretty printed list output (for compatibility with procps) (diff)
downloadkernel-qcow2-util-linux-f546276e2272c5e026f6a2ff667e50bca09d0ee7.tar.gz
kernel-qcow2-util-linux-f546276e2272c5e026f6a2ff667e50bca09d0ee7.tar.xz
kernel-qcow2-util-linux-f546276e2272c5e026f6a2ff667e50bca09d0ee7.zip
kill: support --list=<signal>
The '=' is expected for optional arguments and required in procps version. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'misc-utils/kill.c')
-rw-r--r--misc-utils/kill.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/misc-utils/kill.c b/misc-utils/kill.c
index 9b6640be5..63fc2acdc 100644
--- a/misc-utils/kill.c
+++ b/misc-utils/kill.c
@@ -197,9 +197,8 @@ int main (int argc, char *argv[])
printsignals (stdout, 0);
return EXIT_SUCCESS;
}
- if (argc > 2) {
+ if (argc > 2)
return usage (EXIT_FAILURE);
- }
/* argc == 2, accept "kill -l $?" */
arg = argv[1];
if ((numsig = arg_to_signum (arg, 1)) < 0)
@@ -207,6 +206,14 @@ int main (int argc, char *argv[])
printsig (numsig);
return EXIT_SUCCESS;
}
+ /* for compatibility with procps kill(1) */
+ if (! strncmp (arg, "--list=", 7) || ! strncmp (arg, "-l=", 3)) {
+ char *p = strchr(arg, '=') + 1;
+ if ((numsig = arg_to_signum(p, 1)) < 0)
+ errx(EXIT_FAILURE, _("unknown signal: %s"), p);
+ printsig (numsig);
+ return EXIT_SUCCESS;
+ }
if (! strcmp (arg, "-L") || ! strcmp (arg, "--table")) {
printsignals (stdout, 1);
return EXIT_SUCCESS;
@@ -453,13 +460,13 @@ static int usage(int status)
fputs(USAGE_HEADER, out);
fprintf(out, _(" %s [options] <pid|name> [...]\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
- fputs(_(" -a, --all do not restrict the name-to-pid conversion to processes\n"
- " with the same uid as the present process\n"), out);
- fputs(_(" -s, --signal <sig> send specified signal\n"), out);
- fputs(_(" -q, --queue <sig> use sigqueue(2) rather than kill(2)\n"), out);
- fputs(_(" -p, --pid print pids without signaling them\n"), out);
- fputs(_(" -l, --list <name> list signal names\n"), out);
- fputs(_(" -L, --table list signal names and numbers\n"), out);
+ fputs(_(" -a, --all do not restrict the name-to-pid conversion to processes\n"
+ " with the same uid as the present process\n"), out);
+ fputs(_(" -s, --signal <sig> send specified signal\n"), out);
+ fputs(_(" -q, --queue <sig> use sigqueue(2) rather than kill(2)\n"), out);
+ fputs(_(" -p, --pid print pids without signaling them\n"), out);
+ fputs(_(" -l, --list [=<signal>] list signal names, or convert one to a name\n"), out);
+ fputs(_(" -L, --table list signal names and numbers\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);