diff --git a/man/loginctl.xml b/man/loginctl.xml index d3745ce52d..33683144fa 100644 --- a/man/loginctl.xml +++ b/man/loginctl.xml @@ -334,13 +334,14 @@ - When used with kill-session - or kill-user, choose which signal to send - to selected processes. Must be one of the well known signal - specifiers, such as SIGTERM, - SIGINT or SIGSTOP. - If omitted, defaults to - SIGTERM. + When used with kill-session or kill-user, + choose which signal to send to selected processes. Must be one of the well known signal specifiers, + such as SIGTERM, SIGINT or SIGSTOP. + If omitted, defaults to SIGTERM. + + The special value help will list the known values and the program will exit + immediately, and the special value list will list known values along with the + numerical signal numbers and the program will exit immediately. diff --git a/man/standard-options.xml b/man/standard-options.xml index 848439119e..4565a43b24 100644 --- a/man/standard-options.xml +++ b/man/standard-options.xml @@ -73,7 +73,8 @@ . The special value help will list the known values and the program will exit - immediately. + immediately, and the special value list will list known values along with the + numerical signal numbers and the program will exit immediately. diff --git a/src/shared/parse-argument.c b/src/shared/parse-argument.c index a30d3adc13..ca10d51793 100644 --- a/src/shared/parse-argument.c +++ b/src/shared/parse-argument.c @@ -1,7 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ +#include "format-table.h" #include "parse-argument.h" #include "signal-util.h" +#include "stdio-util.h" #include "string-table.h" #include "string-util.h" @@ -16,6 +18,29 @@ int parse_signal_argument(const char *s, int *ret) { return 0; } + if (streq(s, "list")) { + _cleanup_(table_unrefp) Table *table = NULL; + + table = table_new("signal", "name"); + if (!table) + return log_oom(); + + for (int i = 1; i < _NSIG; i++) { + r = table_add_many( + table, + TABLE_INT, i, + TABLE_SIGNAL, i); + if (r < 0) + return table_log_add_error(r); + } + + r = table_print(table, NULL); + if (r < 0) + return table_log_print_error(r); + + return 0; + } + r = signal_from_string(s); if (r < 0) return log_error_errno(r, "Failed to parse signal string \"%s\".", s);