diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 14:03:46 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 16:48:21 +0100 |
commit | a34c79d0067b79cc27748f70092861ddd942a039 (patch) | |
tree | 07b0182e1ec5d6dacb3542f28c76a6ef5ee389ae /src/sysctl | |
parent | ec5e5948315c856077861b06162ffbc4a83c5b79 (diff) | |
download | systemd-a34c79d0067b79cc27748f70092861ddd942a039.tar.gz |
basic/main-func: also close the pager automatically
We generally want to close the pager last. This patch closes the pager last,
after the static destuctor calls. This means that they can do logging and such
like during normal program runtime.
Diffstat (limited to 'src/sysctl')
-rw-r--r-- | src/sysctl/sysctl.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index f9d282d1cb..d04a2cff15 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -266,21 +266,19 @@ static int parse_argv(int argc, char *argv[]) { static int run(int argc, char *argv[]) { _cleanup_(ordered_hashmap_free_free_freep) OrderedHashmap *sysctl_options = NULL; - int r = 0, k; + int r, k; r = parse_argv(argc, argv); if (r <= 0) - goto finish; + return r; log_setup_service(); umask(0022); sysctl_options = ordered_hashmap_new(&path_hash_ops); - if (!sysctl_options) { - r = log_oom(); - goto finish; - } + if (!sysctl_options) + return log_oom(); r = 0; @@ -297,16 +295,13 @@ static int run(int argc, char *argv[]) { char **f; r = conf_files_list_strv(&files, ".conf", NULL, 0, (const char**) CONF_PATHS_STRV("sysctl.d")); - if (r < 0) { - log_error_errno(r, "Failed to enumerate sysctl.d files: %m"); - goto finish; - } + if (r < 0) + return log_error_errno(r, "Failed to enumerate sysctl.d files: %m"); if (arg_cat_config) { (void) pager_open(arg_pager_flags); - r = cat_files(NULL, files, 0); - goto finish; + return cat_files(NULL, files, 0); } STRV_FOREACH(f, files) { @@ -320,9 +315,6 @@ static int run(int argc, char *argv[]) { if (k < 0 && r == 0) r = k; -finish: - pager_close(); - return r; } |