From: Karel Zak Date: Wed, 13 Mar 2013 15:02:55 +0000 (+0100) Subject: kill: support --list= X-Git-Tag: v2.23-rc1~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f546276e2272c5e026f6a2ff667e50bca09d0ee7;p=thirdparty%2Futil-linux.git kill: support --list= The '=' is expected for optional arguments and required in procps version. Signed-off-by: Karel Zak --- diff --git a/misc-utils/kill.1 b/misc-utils/kill.1 index 34d3dfa68e..50f5cd2061 100644 --- a/misc-utils/kill.1 +++ b/misc-utils/kill.1 @@ -71,7 +71,8 @@ Specify the signal to send. The signal may be given as a signal name or number. .TP \fB\-l\fR, \fB\-\-list\fR [\fIsignal\fR] -Print a list of signal names. These are found in +Print a list of signal names, or convert signal given as argument to a name. +The signals are found in .I /usr/\:include/\:linux/\:signal.h .TP \fB\-L\fR, \fB\-\-table\fR diff --git a/misc-utils/kill.c b/misc-utils/kill.c index 9b6640be5a..63fc2acdcb 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] [...]\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 send specified signal\n"), out); - fputs(_(" -q, --queue use sigqueue(2) rather than kill(2)\n"), out); - fputs(_(" -p, --pid print pids without signaling them\n"), out); - fputs(_(" -l, --list 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 send specified signal\n"), out); + fputs(_(" -q, --queue use sigqueue(2) rather than kill(2)\n"), out); + fputs(_(" -p, --pid print pids without signaling them\n"), out); + fputs(_(" -l, --list [=] 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);