<option>all</option>.</para></listitem>
</varlistentry>
- <varlistentry>
- <term><option>-s</option></term>
- <term><option>--signal=</option></term>
-
- <listitem><para>When used with <command>kill</command>, choose
- which signal to send to selected processes. Must be one of the
- well-known signal specifiers, such as
- <constant>SIGTERM</constant>, <constant>SIGINT</constant> or
- <constant>SIGSTOP</constant>. If omitted, defaults to
- <constant>SIGTERM</constant>.</para></listitem>
- </varlistentry>
+ <xi:include href="standard-options.xml" xpointer="signal" />
<varlistentry>
<term><option>--uid=</option></term>
(for a pretty version of the same, with indentation and line breaks) or <literal>off</literal> (to turn
off JSON output, the default).</para></listitem>
</varlistentry>
+
+ <varlistentry id='signal'>
+ <term><option>-s</option></term>
+ <term><option>--signal=</option></term>
+
+ <listitem>
+ <para>When used with <command>kill</command>, choose which signal to send to selected processes. Must
+ be one of the well-known signal specifiers such as <constant>SIGTERM</constant>,
+ <constant>SIGINT</constant> or <constant>SIGSTOP</constant>. If omitted, defaults to
+ <option>SIGTERM</option>.</para>
+
+ <para>The special value <literal>help</literal> will list the known values and the program will exit
+ immediately.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
is defined. If omitted, defaults to
<option>all</option>.</para>
</listitem>
-
</varlistentry>
- <varlistentry>
- <term><option>-s</option></term>
- <term><option>--signal=</option></term>
-
- <listitem>
- <para>When used with <command>kill</command>, choose which
- signal to send to selected processes. Must be one of the
- well-known signal specifiers such as <constant>SIGTERM</constant>, <constant>SIGINT</constant> or
- <constant>SIGSTOP</constant>. If omitted, defaults to
- <option>SIGTERM</option>.</para>
- </listitem>
- </varlistentry>
+ <xi:include href="standard-options.xml" xpointer="signal" />
<varlistentry>
<term><option>--what=</option></term>
#include "main-func.h"
#include "memory-util.h"
#include "pager.h"
+#include "parse-argument.h"
#include "parse-util.h"
#include "pretty-print.h"
#include "process-util.h"
break;
case 's':
- if (streq(optarg, "help")) {
- DUMP_STRING_TABLE(signal, int, _NSIG);
- return 0;
- }
-
- arg_signal = signal_from_string(optarg);
- if (arg_signal < 0)
- return log_error_errno(arg_signal, "Failed to parse signal string %s.", optarg);
+ r = parse_signal_argument(optarg, &arg_signal);
+ if (r <= 0)
+ return r;
break;
case 'H':
#include "mkdir.h"
#include "nulstr-util.h"
#include "pager.h"
+#include "parse-argument.h"
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
break;
case 's':
- if (streq(optarg, "help")) {
- DUMP_STRING_TABLE(signal, int, _NSIG);
- return 0;
- }
-
- r = signal_from_string(optarg);
- if (r < 0)
- return log_error_errno(r, "Failed to parse signal string %s.", optarg);
- arg_signal = r;
+ r = parse_signal_argument(optarg, &arg_signal);
+ if (r <= 0)
+ return r;
break;
case ARG_NO_ASK_PASSWORD:
output-mode.h
pager.c
pager.h
+ parse-argument.c
+ parse-argument.h
pe-header.h
pkcs11-util.c
pkcs11-util.h
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "parse-argument.h"
+#include "signal-util.h"
+#include "string-table.h"
+#include "string-util.h"
+
+int parse_signal_argument(const char *s, int *ret) {
+ int r;
+
+ assert(s);
+ assert(ret);
+
+ if (streq(s, "help")) {
+ DUMP_STRING_TABLE(signal, int, _NSIG);
+ return 0;
+ }
+
+ r = signal_from_string(s);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse signal string \"%s\".", s);
+
+ *ret = r;
+ return 1; /* work to do */
+}
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+int parse_signal_argument(const char *s, int *ret);
#include "main-func.h"
#include "output-mode.h"
#include "pager.h"
+#include "parse-argument.h"
#include "path-util.h"
#include "pretty-print.h"
#include "rlimit-util.h"
break;
case 's':
- if (streq(optarg, "help")) {
- DUMP_STRING_TABLE(signal, int, _NSIG);
- return 0;
- }
-
- arg_signal = signal_from_string(optarg);
- if (arg_signal < 0)
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "Failed to parse signal string %s.",
- optarg);
+ r = parse_signal_argument(optarg, &arg_signal);
+ if (r <= 0)
+ return r;
break;
case ARG_NO_ASK_PASSWORD: