Merge pull request #13219 from poettering/named-exit-codes-tweaks
quick follow-up for the symbolic exit status PR #13207
This commit is contained in:
commit
e397eb50da
6
NEWS
6
NEWS
|
@ -106,9 +106,9 @@ CHANGES WITH 243 in spe:
|
||||||
unambiguously distinguished.
|
unambiguously distinguished.
|
||||||
|
|
||||||
* SuccessExitStatus=, RestartPreventExitStatus=, and
|
* SuccessExitStatus=, RestartPreventExitStatus=, and
|
||||||
RestartForceExitStatus= now accept exit code names (e.g. "DATAERR" is
|
RestartForceExitStatus= now accept exit status names (e.g. "DATAERR"
|
||||||
equivalent to "65"). systemd-analyze learnt a new 'exit-codes' verb
|
is equivalent to "65"). systemd-analyze learnt a new 'exit-status'
|
||||||
to display those exit code name mappings.
|
verb to display those exit status name mappings.
|
||||||
|
|
||||||
* /usr/sbin/halt.local is no longer supported. Implementation in
|
* /usr/sbin/halt.local is no longer supported. Implementation in
|
||||||
distributions was inconsistent and it seems this functionality was
|
distributions was inconsistent and it seems this functionality was
|
||||||
|
|
|
@ -86,8 +86,8 @@
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>systemd-analyze</command>
|
<command>systemd-analyze</command>
|
||||||
<arg choice="opt" rep="repeat">OPTIONS</arg>
|
<arg choice="opt" rep="repeat">OPTIONS</arg>
|
||||||
<arg choice="plain">exit-codes</arg>
|
<arg choice="plain">exit-status</arg>
|
||||||
<arg choice="opt" rep="repeat"><replaceable>CODE</replaceable></arg>
|
<arg choice="opt" rep="repeat"><replaceable>STATUS</replaceable></arg>
|
||||||
</cmdsynopsis>
|
</cmdsynopsis>
|
||||||
<cmdsynopsis>
|
<cmdsynopsis>
|
||||||
<command>systemd-analyze</command>
|
<command>systemd-analyze</command>
|
||||||
|
@ -372,20 +372,20 @@ $ eog targets.svg</programlisting>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
|
|
||||||
<refsect2>
|
<refsect2>
|
||||||
<title><command>systemd-analyze exit-codes <optional><replaceable>CODE</replaceable>...</optional></command></title>
|
<title><command>systemd-analyze exit-status <optional><replaceable>STATUS</replaceable>...</optional></command></title>
|
||||||
|
|
||||||
<para>This command prints a list of exit codes along with their "class", i.e. the source of the
|
<para>This command prints a list of exit statuses along with their "class", i.e. the source of the
|
||||||
definition (one of <literal>glibc</literal>, <literal>systemd</literal>, <literal>LSB</literal>, or
|
definition (one of <literal>glibc</literal>, <literal>systemd</literal>, <literal>LSB</literal>, or
|
||||||
<literal>BSD</literal>), see the Process Exit Codes section in
|
<literal>BSD</literal>), see the Process Exit Codes section in
|
||||||
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
|
||||||
If no additional arguments are specified, all known codes are are shown. Otherwise, only the
|
If no additional arguments are specified, all known statuses are are shown. Otherwise, only the
|
||||||
definitions for the specified codes are shown.</para>
|
definitions for the specified codes are shown.</para>
|
||||||
|
|
||||||
<example>
|
<example>
|
||||||
<title><command>Show some example exit code names</command></title>
|
<title><command>Show some example exit status names</command></title>
|
||||||
|
|
||||||
<programlisting>$ systemd-analyze exit-codes 0 1 {63..65}
|
<programlisting>$ systemd-analyze exit-status 0 1 {63..65}
|
||||||
NAME CODE CLASS
|
NAME STATUS CLASS
|
||||||
SUCCESS 0 glibc
|
SUCCESS 0 glibc
|
||||||
FAILURE 1 glibc
|
FAILURE 1 glibc
|
||||||
- 63 -
|
- 63 -
|
||||||
|
|
|
@ -2718,8 +2718,7 @@ StandardInputData=SWNrIHNpdHplIGRhIHVuJyBlc3NlIEtsb3BzLAp1ZmYgZWVtYWwga2xvcHAncy
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<para>The following service exit codes are defined by the <ulink
|
<para>The following service exit codes are defined by the <ulink
|
||||||
url="https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html">LSB specification
|
url="https://refspecs.linuxbase.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html">LSB specification</ulink>.
|
||||||
</ulink>.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|
|
@ -1638,14 +1638,18 @@ static void dump_syscall_filter(const SyscallFilterSet *set) {
|
||||||
printf(" %s%s%s\n", syscall[0] == '@' ? ansi_underline() : "", syscall, ansi_normal());
|
printf(" %s%s%s\n", syscall[0] == '@' ? ansi_underline() : "", syscall, ansi_normal());
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dump_exit_codes(int argc, char *argv[], void *userdata) {
|
static int dump_exit_status(int argc, char *argv[], void *userdata) {
|
||||||
_cleanup_(table_unrefp) Table *table = NULL;
|
_cleanup_(table_unrefp) Table *table = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
table = table_new("name", "code", "class");
|
table = table_new("name", "status", "class");
|
||||||
if (!table)
|
if (!table)
|
||||||
return log_oom();
|
return log_oom();
|
||||||
|
|
||||||
|
r = table_set_align_percent(table, table_get_cell(table, 0, 1), 100);
|
||||||
|
if (r < 0)
|
||||||
|
return log_error_errno(r, "Failed to right-align status: %m");
|
||||||
|
|
||||||
if (strv_isempty(strv_skip(argv, 1)))
|
if (strv_isempty(strv_skip(argv, 1)))
|
||||||
for (size_t i = 0; i < ELEMENTSOF(exit_status_mappings); i++) {
|
for (size_t i = 0; i < ELEMENTSOF(exit_status_mappings); i++) {
|
||||||
if (!exit_status_mappings[i].name)
|
if (!exit_status_mappings[i].name)
|
||||||
|
@ -1653,24 +1657,24 @@ static int dump_exit_codes(int argc, char *argv[], void *userdata) {
|
||||||
|
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
TABLE_STRING, exit_status_mappings[i].name,
|
TABLE_STRING, exit_status_mappings[i].name,
|
||||||
TABLE_UINT, i,
|
TABLE_INT, (int) i,
|
||||||
TABLE_STRING, exit_status_class(i));
|
TABLE_STRING, exit_status_class(i));
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
int code;
|
int status;
|
||||||
|
|
||||||
code = exit_status_from_string(argv[i]);
|
status = exit_status_from_string(argv[i]);
|
||||||
if (code < 0)
|
if (status < 0)
|
||||||
return log_error_errno(r, "Invalid exit code \"%s\": %m", argv[i]);
|
return log_error_errno(r, "Invalid exit status \"%s\": %m", argv[i]);
|
||||||
|
|
||||||
assert(code >= 0 && (size_t) code < ELEMENTSOF(exit_status_mappings));
|
assert(status >= 0 && (size_t) status < ELEMENTSOF(exit_status_mappings));
|
||||||
r = table_add_many(table,
|
r = table_add_many(table,
|
||||||
TABLE_STRING, exit_status_mappings[code].name ?: "-",
|
TABLE_STRING, exit_status_mappings[status].name ?: "-",
|
||||||
TABLE_UINT, code,
|
TABLE_INT, status,
|
||||||
TABLE_STRING, exit_status_class(code) ?: "-");
|
TABLE_STRING, exit_status_class(status) ?: "-");
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -2213,7 +2217,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||||
" dump Output state serialization of service manager\n"
|
" dump Output state serialization of service manager\n"
|
||||||
" cat-config Show configuration file and drop-ins\n"
|
" cat-config Show configuration file and drop-ins\n"
|
||||||
" unit-paths List load directories for units\n"
|
" unit-paths List load directories for units\n"
|
||||||
" exit-codes List exit code definitions\n"
|
" exit-status [STATUS...] List exit status definitions\n"
|
||||||
" syscall-filter [NAME...] Print list of syscalls in seccomp filter\n"
|
" syscall-filter [NAME...] Print list of syscalls in seccomp filter\n"
|
||||||
" condition CONDITION... Evaluate conditions and asserts\n"
|
" condition CONDITION... Evaluate conditions and asserts\n"
|
||||||
" verify FILE... Check unit files for correctness\n"
|
" verify FILE... Check unit files for correctness\n"
|
||||||
|
@ -2418,7 +2422,7 @@ static int run(int argc, char *argv[]) {
|
||||||
{ "dump", VERB_ANY, 1, 0, dump },
|
{ "dump", VERB_ANY, 1, 0, dump },
|
||||||
{ "cat-config", 2, VERB_ANY, 0, cat_config },
|
{ "cat-config", 2, VERB_ANY, 0, cat_config },
|
||||||
{ "unit-paths", 1, 1, 0, dump_unit_paths },
|
{ "unit-paths", 1, 1, 0, dump_unit_paths },
|
||||||
{ "exit-codes", VERB_ANY, VERB_ANY, 0, dump_exit_codes },
|
{ "exit-status", VERB_ANY, VERB_ANY, 0, dump_exit_status },
|
||||||
{ "syscall-filter", VERB_ANY, VERB_ANY, 0, dump_syscall_filters },
|
{ "syscall-filter", VERB_ANY, VERB_ANY, 0, dump_syscall_filters },
|
||||||
{ "condition", 2, VERB_ANY, 0, do_condition },
|
{ "condition", 2, VERB_ANY, 0, do_condition },
|
||||||
{ "verify", 2, VERB_ANY, 0, do_verify },
|
{ "verify", 2, VERB_ANY, 0, do_verify },
|
||||||
|
|
|
@ -3881,7 +3881,7 @@ int exec_spawn(Unit *unit,
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
const char *status =
|
const char *status =
|
||||||
exit_status_to_string(exit_status,
|
exit_status_to_string(exit_status,
|
||||||
EXIT_STATUS_GLIBC | EXIT_STATUS_SYSTEMD);
|
EXIT_STATUS_LIBC | EXIT_STATUS_SYSTEMD);
|
||||||
|
|
||||||
log_struct_errno(LOG_ERR, r,
|
log_struct_errno(LOG_ERR, r,
|
||||||
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
"MESSAGE_ID=" SD_MESSAGE_SPAWN_FAILED_STR,
|
||||||
|
|
|
@ -223,7 +223,7 @@ _noreturn_ static void crash(int sig) {
|
||||||
log_emergency_errno(r, "Caught <%s>, waitpid() failed: %m", signal_to_string(sig));
|
log_emergency_errno(r, "Caught <%s>, waitpid() failed: %m", signal_to_string(sig));
|
||||||
else if (status.si_code != CLD_DUMPED) {
|
else if (status.si_code != CLD_DUMPED) {
|
||||||
const char *s = status.si_code == CLD_EXITED
|
const char *s = status.si_code == CLD_EXITED
|
||||||
? exit_status_to_string(status.si_status, EXIT_STATUS_GLIBC)
|
? exit_status_to_string(status.si_status, EXIT_STATUS_LIBC)
|
||||||
: signal_to_string(status.si_status);
|
: signal_to_string(status.si_status);
|
||||||
|
|
||||||
log_emergency("Caught <%s>, core dump failed (child "PID_FMT", code=%s, status=%i/%s).",
|
log_emergency("Caught <%s>, core dump failed (child "PID_FMT", code=%s, status=%i/%s).",
|
||||||
|
|
|
@ -26,8 +26,8 @@ const ExitStatusMapping exit_status_mappings[256] = {
|
||||||
* │ signal or such, and we follow that logic here.)
|
* │ signal or such, and we follow that logic here.)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[EXIT_SUCCESS] = { "SUCCESS", EXIT_STATUS_GLIBC },
|
[EXIT_SUCCESS] = { "SUCCESS", EXIT_STATUS_LIBC },
|
||||||
[EXIT_FAILURE] = { "FAILURE", EXIT_STATUS_GLIBC },
|
[EXIT_FAILURE] = { "FAILURE", EXIT_STATUS_LIBC },
|
||||||
|
|
||||||
[EXIT_CHDIR] = { "CHDIR", EXIT_STATUS_SYSTEMD },
|
[EXIT_CHDIR] = { "CHDIR", EXIT_STATUS_SYSTEMD },
|
||||||
[EXIT_NICE] = { "NICE", EXIT_STATUS_SYSTEMD },
|
[EXIT_NICE] = { "NICE", EXIT_STATUS_SYSTEMD },
|
||||||
|
@ -107,8 +107,8 @@ const char* exit_status_class(int code) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (exit_status_mappings[code].class) {
|
switch (exit_status_mappings[code].class) {
|
||||||
case EXIT_STATUS_GLIBC:
|
case EXIT_STATUS_LIBC:
|
||||||
return "glibc";
|
return "libc";
|
||||||
case EXIT_STATUS_SYSTEMD:
|
case EXIT_STATUS_SYSTEMD:
|
||||||
return "systemd";
|
return "systemd";
|
||||||
case EXIT_STATUS_LSB:
|
case EXIT_STATUS_LSB:
|
||||||
|
|
|
@ -75,11 +75,11 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum ExitStatusClass {
|
typedef enum ExitStatusClass {
|
||||||
EXIT_STATUS_GLIBC = 1 << 0, /* libc EXIT_STATUS/EXIT_FAILURE */
|
EXIT_STATUS_LIBC = 1 << 0, /* libc EXIT_STATUS/EXIT_FAILURE */
|
||||||
EXIT_STATUS_SYSTEMD = 1 << 1, /* systemd's own exit codes */
|
EXIT_STATUS_SYSTEMD = 1 << 1, /* systemd's own exit codes */
|
||||||
EXIT_STATUS_LSB = 1 << 2, /* LSB exit codes */
|
EXIT_STATUS_LSB = 1 << 2, /* LSB exit codes */
|
||||||
EXIT_STATUS_BSD = 1 << 3, /* BSD (EX_xyz) exit codes */
|
EXIT_STATUS_BSD = 1 << 3, /* BSD (EX_xyz) exit codes */
|
||||||
EXIT_STATUS_FULL = EXIT_STATUS_GLIBC | EXIT_STATUS_SYSTEMD | EXIT_STATUS_LSB | EXIT_STATUS_BSD,
|
EXIT_STATUS_FULL = EXIT_STATUS_LIBC | EXIT_STATUS_SYSTEMD | EXIT_STATUS_LSB | EXIT_STATUS_BSD,
|
||||||
} ExitStatusClass;
|
} ExitStatusClass;
|
||||||
|
|
||||||
typedef struct ExitStatusSet {
|
typedef struct ExitStatusSet {
|
||||||
|
|
|
@ -4380,7 +4380,7 @@ static void print_status_info(
|
||||||
|
|
||||||
printf("status=%i", p->status);
|
printf("status=%i", p->status);
|
||||||
|
|
||||||
c = exit_status_to_string(p->status, EXIT_STATUS_GLIBC | EXIT_STATUS_SYSTEMD);
|
c = exit_status_to_string(p->status, EXIT_STATUS_LIBC | EXIT_STATUS_SYSTEMD);
|
||||||
if (c)
|
if (c)
|
||||||
printf("/%s", c);
|
printf("/%s", c);
|
||||||
|
|
||||||
|
@ -4422,7 +4422,7 @@ static void print_status_info(
|
||||||
printf("status=%i", i->exit_status);
|
printf("status=%i", i->exit_status);
|
||||||
|
|
||||||
c = exit_status_to_string(i->exit_status,
|
c = exit_status_to_string(i->exit_status,
|
||||||
EXIT_STATUS_GLIBC | EXIT_STATUS_SYSTEMD);
|
EXIT_STATUS_LIBC | EXIT_STATUS_SYSTEMD);
|
||||||
if (c)
|
if (c)
|
||||||
printf("/%s", c);
|
printf("/%s", c);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue