diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-21 18:50:34 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-02-22 10:46:26 +0100 |
commit | 1f409a0cbb81e2fb55281623c836e117e77b5e32 (patch) | |
tree | e7fb3ebd59d7c031368ef08c300ed2597e2fcda7 /src | |
parent | c01dcddf803a009dd9118dee0873cb9dd1dd02ce (diff) | |
download | systemd-1f409a0cbb81e2fb55281623c836e117e77b5e32.tar.gz |
shutdown: let's not use exit() needlessly
Generally we prefer 'return' from main() over exit() so that automatic
cleanups and such work correct. Let's do that in shutdown.c too, becuase
there's not really any reason not to.
With this we are pretty good in consistently using return from main()
rather than exit() all across the codebase. Yay!
Diffstat (limited to 'src')
-rw-r--r-- | src/core/shutdown.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/core/shutdown.c b/src/core/shutdown.c index de689aea31..58c9a9de79 100644 --- a/src/core/shutdown.c +++ b/src/core/shutdown.c @@ -485,12 +485,9 @@ int main(int argc, char *argv[]) { if (streq(arg_verb, "exit")) { if (in_container) - exit(arg_exit_code); - else { - /* We cannot exit() on the host, fallback on another - * method. */ - cmd = RB_POWER_OFF; - } + return arg_exit_code; + + cmd = RB_POWER_OFF; /* We cannot exit() on the host, fallback on another method. */ } switch (cmd) { @@ -542,7 +539,7 @@ int main(int argc, char *argv[]) { * CAP_SYS_BOOT just exit, this will kill our * container for good. */ log_info("Exiting container."); - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } r = log_error_errno(errno, "Failed to invoke reboot(): %m"); |