diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-10-29 18:07:07 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-11-05 21:38:21 +0100 |
commit | 7f3614e5479446bbd5a2bdf6aed4962e8d803e35 (patch) | |
tree | 6ee77de900700d8e70487cc643b2fb19ce236f34 /src/run/run.c | |
parent | f1d60962e5f21e2af7af9e8bc06ecf28da89e1b1 (diff) | |
download | systemd-7f3614e5479446bbd5a2bdf6aed4962e8d803e35.tar.gz |
run: propagate return code/status from the child
Fixes #13756. We were returning things that didn't make much sense:
we would always use the exit_code value as the exit code. But it sometimes
contains a exit code from the process, and sometimes the number of a signal
that was used to kill the process. We would also ignore SuccessExitStatus=
and in general whether systemd thinks the service exited successfully
(hence the issue in #13756, where systemd would return success/SIGTERM,
but we'd just look at the SIGTERM part.)
If we are doing --wait, let's always propagate the exit code/status from
the child.
While at it, make the documentation useful.
Diffstat (limited to 'src/run/run.c')
-rw-r--r-- | src/run/run.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/run/run.c b/src/run/run.c index 3d63cf0254..de968caf3f 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -16,6 +16,7 @@ #include "bus-wait-for-jobs.h" #include "calendarspec.h" #include "env-util.h" +#include "exit-status.h" #include "fd-util.h" #include "format-util.h" #include "main-func.h" @@ -1303,9 +1304,14 @@ static int start_transient_service( } } - /* Try to propagate the service's return value */ - if (c.result && STR_IN_SET(c.result, "success", "exit-code") && c.exit_code == CLD_EXITED) + /* Try to propagate the service's return value. But if the service defines + * e.g. SuccessExitStatus, honour this, and return 0 to mean "success". */ + if (streq_ptr(c.result, "success")) + *retval = 0; + else if (streq_ptr(c.result, "exit-code") && c.exit_status > 0) *retval = c.exit_status; + else if (streq_ptr(c.result, "signal")) + *retval = EXIT_EXCEPTION; else *retval = EXIT_FAILURE; } |