mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-03 01:17:45 +03:00
Merge pull request #20138 from keszybz/coding-style-variable-decls
A coding style tweak and checking of sd_notify() calls and voidification of pager_open()
This commit is contained in:
commit
8389fd19d2
@ -153,25 +153,34 @@ SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
## Using C Constructs
|
||||
|
||||
- Allocate local variables where it makes sense: at the top of the block, or at
|
||||
the point where they can be initialized. `r` is typically used for a local
|
||||
state variable, but should almost always be declared at the top of the
|
||||
function.
|
||||
the point where they can be initialized. Avoid huge variable declaration
|
||||
lists at the top of the function.
|
||||
|
||||
As an exception, `r` is typically used for a local state variable, but should
|
||||
almost always be declared as the last variable at the top of the function.
|
||||
|
||||
```c
|
||||
{
|
||||
uint64_t a, b;
|
||||
uint64_t a;
|
||||
int r;
|
||||
|
||||
a = frobnicate();
|
||||
b = a + 5;
|
||||
|
||||
r = do_something();
|
||||
r = frobnicate(&a);
|
||||
if (r < 0)
|
||||
…
|
||||
|
||||
uint64_t b = a + 1, c;
|
||||
|
||||
r = foobarify(a, b, &c);
|
||||
if (r < 0)
|
||||
…
|
||||
|
||||
const char *pretty = prettify(a, b, c);
|
||||
…
|
||||
}
|
||||
```
|
||||
|
||||
- Do not mix function invocations with variable definitions in one line.
|
||||
- Do not mix multiple variable definitions with function invocations or
|
||||
complicated expressions:
|
||||
|
||||
```c
|
||||
{
|
||||
@ -225,7 +234,7 @@ SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
- To determine the length of a constant string `"foo"`, don't bother with
|
||||
`sizeof("foo")-1`, please use `strlen()` instead (both gcc and clang optimize
|
||||
the call away for fixed strings). The only exception is when declaring an
|
||||
array. In that case use STRLEN, which evaluates to a static constant and
|
||||
array. In that case use `STRLEN()`, which evaluates to a static constant and
|
||||
doesn't force the compiler to create a VLA.
|
||||
|
||||
- Please use C's downgrade-to-bool feature only for expressions that are
|
||||
|
@ -1051,7 +1051,7 @@ static int analyze_critical_chain(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
unit_times_hashmap = h;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
puts("The time when unit became active or started is printed after the \"@\" character.\n"
|
||||
"The time the unit took to start is printed after the \"+\" character.\n");
|
||||
@ -1121,7 +1121,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return table_print(table, NULL);
|
||||
}
|
||||
@ -1349,7 +1349,7 @@ static int dump(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return bus_log_connect_error(r, arg_transport);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (!sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD))
|
||||
return dump_fallback(bus);
|
||||
@ -1376,7 +1376,7 @@ static int cat_config(int argc, char *argv[], void *userdata) {
|
||||
char **arg, **list;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
list = strv_skip(argv, 1);
|
||||
STRV_FOREACH(arg, list) {
|
||||
@ -1523,7 +1523,7 @@ static int dump_exit_status(int argc, char *argv[], void *userdata) {
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return table_print(table, NULL);
|
||||
}
|
||||
@ -1568,7 +1568,7 @@ static int dump_capabilities(int argc, char *argv[], void *userdata) {
|
||||
(void) table_set_sort(table, (size_t) 1);
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return table_print(table, NULL);
|
||||
}
|
||||
@ -1652,7 +1652,7 @@ static void dump_syscall_filter(const SyscallFilterSet *set) {
|
||||
static int dump_syscall_filters(int argc, char *argv[], void *userdata) {
|
||||
bool first = true;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (strv_isempty(strv_skip(argv, 1))) {
|
||||
_cleanup_set_free_ Set *kernel = NULL, *known = NULL;
|
||||
@ -1824,7 +1824,7 @@ static int dump_filesystems(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "Not compiled with libbpf support, sorry.");
|
||||
#endif
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (strv_isempty(strv_skip(argv, 1))) {
|
||||
_cleanup_set_free_ Set *kernel = NULL, *known = NULL;
|
||||
@ -2270,7 +2270,7 @@ static int do_security(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return bus_log_connect_error(r, arg_transport);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_security_policy) {
|
||||
r = json_parse_file(/*f=*/ NULL, arg_security_policy, /*flags=*/ 0, &policy, &line, &column);
|
||||
@ -2309,7 +2309,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *link = NULL, *dot_link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("systemd-analyze", "1", &link);
|
||||
if (r < 0)
|
||||
|
@ -217,7 +217,7 @@ static int run(int argc, char *argv[]) {
|
||||
return log_error_errno(r, "Failed to enumerate binfmt.d files: %m");
|
||||
|
||||
if (arg_cat_config) {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return cat_files(NULL, files, 0);
|
||||
}
|
||||
|
@ -1286,7 +1286,7 @@ static int verb_status(int argc, char *argv[], void *userdata) {
|
||||
r = 0; /* If we couldn't determine the path, then don't consider that a problem from here on, just show what we
|
||||
* can show */
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (is_efi_boot()) {
|
||||
static const struct {
|
||||
@ -1444,7 +1444,7 @@ static int verb_list(int argc, char *argv[], void *userdata) {
|
||||
if (config.n_entries == 0)
|
||||
log_info("No boot loader entries found.");
|
||||
else {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
printf("Boot Loader Entries:\n");
|
||||
|
||||
|
@ -486,7 +486,7 @@ static int tree_one(sd_bus *bus, const char *service) {
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
l = set_get_strv(done);
|
||||
if (!l)
|
||||
@ -526,7 +526,7 @@ static int tree(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get name list: %m");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
STRV_FOREACH(i, names) {
|
||||
int q;
|
||||
@ -556,7 +556,7 @@ static int tree(int argc, char **argv, void *userdata) {
|
||||
printf("\n");
|
||||
|
||||
if (argv[2]) {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
printf("Service %s%s%s:\n", ansi_highlight(), *i, ansi_normal());
|
||||
}
|
||||
|
||||
@ -979,7 +979,7 @@ static int introspect(int argc, char **argv, void *userdata) {
|
||||
|
||||
if (arg_xml_interface) {
|
||||
/* Just dump the received XML and finish */
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
puts(xml);
|
||||
return 0;
|
||||
}
|
||||
@ -1098,7 +1098,7 @@ static int introspect(int argc, char **argv, void *userdata) {
|
||||
|
||||
typesafe_qsort(sorted, k, member_compare_funcp);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_legend)
|
||||
printf("%-*s %-*s %-*s %-*s %s\n",
|
||||
@ -1358,7 +1358,7 @@ static int status(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (!isempty(argv[1])) {
|
||||
r = parse_pid(argv[1], &pid);
|
||||
@ -2038,7 +2038,7 @@ static int call(int argc, char **argv, void *userdata) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
|
||||
|
||||
if (arg_json_format_flags & (JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO))
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = json_transform_message(reply, &v);
|
||||
if (r < 0)
|
||||
@ -2047,7 +2047,7 @@ static int call(int argc, char **argv, void *userdata) {
|
||||
json_variant_dump(v, arg_json_format_flags, NULL, NULL);
|
||||
|
||||
} else if (arg_verbose) {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_message_dump(reply, stdout, 0);
|
||||
if (r < 0)
|
||||
@ -2147,7 +2147,7 @@ static int get_property(int argc, char **argv, void *userdata) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
|
||||
|
||||
if (arg_json_format_flags & (JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO))
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = json_transform_variant(reply, contents, &v);
|
||||
if (r < 0)
|
||||
@ -2156,7 +2156,7 @@ static int get_property(int argc, char **argv, void *userdata) {
|
||||
json_variant_dump(v, arg_json_format_flags, NULL, NULL);
|
||||
|
||||
} else if (arg_verbose) {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_message_dump(reply, stdout, SD_BUS_MESSAGE_DUMP_SUBTREE_ONLY);
|
||||
if (r < 0)
|
||||
@ -2233,7 +2233,7 @@ static int help(void) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
printf("%s [OPTIONS...] COMMAND ...\n\n"
|
||||
"%sIntrospect the D-Bus IPC bus.%s\n"
|
||||
|
@ -191,8 +191,8 @@ static int run(int argc, char *argv[]) {
|
||||
if (r <= 0)
|
||||
return r;
|
||||
|
||||
r = pager_open(arg_pager_flags);
|
||||
if (r > 0 && arg_full < 0)
|
||||
pager_open(arg_pager_flags);
|
||||
if (arg_full < 0 && pager_have())
|
||||
arg_full = true;
|
||||
|
||||
if (arg_full > 0)
|
||||
|
@ -2902,7 +2902,7 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
|
||||
if (IN_SET(arg_action, ACTION_TEST, ACTION_HELP, ACTION_DUMP_CONFIGURATION_ITEMS, ACTION_DUMP_BUS_PROPERTIES, ACTION_BUS_INTROSPECT))
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_action != ACTION_RUN)
|
||||
skip_setup = true;
|
||||
|
@ -3457,27 +3457,38 @@ static void manager_notify_finished(Manager *m) {
|
||||
}
|
||||
|
||||
static void user_manager_send_ready(Manager *m) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
/* We send READY=1 on reaching basic.target only when running in --user mode. */
|
||||
if (!MANAGER_IS_USER(m) || m->ready_sent)
|
||||
return;
|
||||
|
||||
sd_notifyf(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Reached " SPECIAL_BASIC_TARGET ".");
|
||||
r = sd_notify(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Reached " SPECIAL_BASIC_TARGET ".");
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
m->ready_sent = true;
|
||||
m->status_ready = false;
|
||||
}
|
||||
|
||||
static void manager_send_ready(Manager *m) {
|
||||
int r;
|
||||
|
||||
if (m->ready_sent && m->status_ready)
|
||||
/* Skip the notification if nothing changed. */
|
||||
return;
|
||||
|
||||
sd_notifyf(false,
|
||||
"%sSTATUS=Ready.",
|
||||
m->ready_sent ? "READY=1\n" : "");
|
||||
r = sd_notify(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Ready.");
|
||||
if (r < 0)
|
||||
log_full_errno(m->ready_sent ? LOG_DEBUG : LOG_WARNING, r,
|
||||
"Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
m->ready_sent = m->status_ready = true;
|
||||
}
|
||||
|
||||
|
@ -824,7 +824,7 @@ static int dump_list(int argc, char **argv, void *userdata) {
|
||||
|
||||
(void) table_set_empty_string(t, "-");
|
||||
} else
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
/* "info" without pattern implies "-1" */
|
||||
if ((arg_rows_max == 1 && arg_reverse) || (verb_is_info && argc == 1)) {
|
||||
|
@ -649,7 +649,7 @@ static int run(int argc, char *argv[]) {
|
||||
else if (arg_diff)
|
||||
arg_flags |= SHOW_OVERRIDDEN;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (optind < argc) {
|
||||
int i;
|
||||
|
@ -379,7 +379,7 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
|
||||
assert(d);
|
||||
|
||||
if (arg_json_format_flags & (JSON_FORMAT_OFF|JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO))
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_json_format_flags & JSON_FORMAT_OFF)
|
||||
printf(" Name: %s\n", basename(arg_image));
|
||||
|
@ -613,7 +613,7 @@ static int inspect_home(int argc, char *argv[], void *userdata) {
|
||||
int r, ret = 0;
|
||||
char **items, **i;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = acquire_bus(&bus);
|
||||
if (r < 0)
|
||||
@ -2020,7 +2020,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("homectl", "1", &link);
|
||||
if (r < 0)
|
||||
|
@ -327,7 +327,7 @@ static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("journalctl", "1", &link);
|
||||
if (r < 0)
|
||||
@ -1445,7 +1445,7 @@ static int list_boots(sd_journal *j) {
|
||||
if (count == 0)
|
||||
return count;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
/* numbers are one less, but we need an extra char for the sign */
|
||||
w = DECIMAL_STR_WIDTH(count - 1) + 1;
|
||||
@ -2193,7 +2193,7 @@ int main(int argc, char *argv[]) {
|
||||
} else {
|
||||
bool oneline = arg_action == ACTION_LIST_CATALOG;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (optind < argc)
|
||||
r = catalog_list_items(stdout, database, oneline, argv + optind);
|
||||
@ -2586,7 +2586,7 @@ int main(int argc, char *argv[]) {
|
||||
need_seek = true;
|
||||
|
||||
if (!arg_follow)
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (!arg_quiet && (arg_lines != 0 || arg_follow)) {
|
||||
usec_t start, end;
|
||||
|
@ -1764,13 +1764,10 @@ static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents,
|
||||
* there's something to send it will be turned on again. */
|
||||
|
||||
if (!s->sent_notify_ready) {
|
||||
static const char p[] =
|
||||
"READY=1\n"
|
||||
"STATUS=Processing requests...";
|
||||
ssize_t l;
|
||||
static const char p[] = "READY=1\n"
|
||||
"STATUS=Processing requests...";
|
||||
|
||||
l = send(s->notify_fd, p, strlen(p), MSG_DONTWAIT);
|
||||
if (l < 0) {
|
||||
if (send(s->notify_fd, p, strlen(p), MSG_DONTWAIT) < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
|
||||
@ -1781,14 +1778,9 @@ static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents,
|
||||
log_debug("Sent READY=1 notification.");
|
||||
|
||||
} else if (s->send_watchdog) {
|
||||
static const char p[] = "WATCHDOG=1";
|
||||
|
||||
static const char p[] =
|
||||
"WATCHDOG=1";
|
||||
|
||||
ssize_t l;
|
||||
|
||||
l = send(s->notify_fd, p, strlen(p), MSG_DONTWAIT);
|
||||
if (l < 0) {
|
||||
if (send(s->notify_fd, p, strlen(p), MSG_DONTWAIT) < 0) {
|
||||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
|
||||
|
@ -193,7 +193,7 @@ static int list_locales(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to read list of locales: %m");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
strv_print(l);
|
||||
|
||||
return 0;
|
||||
@ -233,7 +233,7 @@ static int list_vconsole_keymaps(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to read list of keymaps: %m");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
strv_print(l);
|
||||
|
||||
@ -362,7 +362,7 @@ static int list_x11_keymaps(int argc, char **argv, void *userdata) {
|
||||
strv_sort(list);
|
||||
strv_uniq(list);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
strv_print(list);
|
||||
return 0;
|
||||
|
@ -70,7 +70,7 @@ static int print_inhibitors(sd_bus *bus) {
|
||||
_cleanup_(table_unrefp) Table *table = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
|
@ -123,7 +123,7 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_call_method(bus, bus_login_mgr, "ListSessions", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
@ -197,7 +197,7 @@ static int list_users(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_call_method(bus, bus_login_mgr, "ListUsers", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
@ -247,7 +247,7 @@ static int list_seats(int argc, char *argv[], void *userdata) {
|
||||
assert(bus);
|
||||
assert(argv);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_call_method(bus, bus_login_mgr, "ListSeats", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
@ -810,7 +810,7 @@ static int show_session(int argc, char *argv[], void *userdata) {
|
||||
|
||||
properties = !strstr(argv[0], "status");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (argc <= 1) {
|
||||
/* If no argument is specified inspect the manager itself */
|
||||
@ -847,7 +847,7 @@ static int show_user(int argc, char *argv[], void *userdata) {
|
||||
|
||||
properties = !strstr(argv[0], "status");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (argc <= 1) {
|
||||
/* If no argument is specified inspect the manager itself */
|
||||
@ -904,7 +904,7 @@ static int show_seat(int argc, char *argv[], void *userdata) {
|
||||
|
||||
properties = !strstr(argv[0], "status");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (argc <= 1) {
|
||||
/* If no argument is specified inspect the manager itself */
|
||||
@ -1219,7 +1219,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("loginctl", "1", &link);
|
||||
if (r < 0)
|
||||
|
@ -384,14 +384,19 @@ error:
|
||||
}
|
||||
|
||||
void session_device_free(SessionDevice *sd) {
|
||||
int r;
|
||||
|
||||
assert(sd);
|
||||
|
||||
/* Make sure to remove the pushed fd. */
|
||||
if (sd->pushed_fd)
|
||||
(void) sd_notifyf(false,
|
||||
"FDSTOREREMOVE=1\n"
|
||||
"FDNAME=session-%s-device-%u-%u",
|
||||
sd->session->id, major(sd->dev), minor(sd->dev));
|
||||
if (sd->pushed_fd) {
|
||||
r = sd_notifyf(false,
|
||||
"FDSTOREREMOVE=1\n"
|
||||
"FDNAME=session-%s-device-%u-%u",
|
||||
sd->session->id, major(sd->dev), minor(sd->dev));
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to remove file descriptor from the store, ignoring: %m");
|
||||
}
|
||||
|
||||
session_device_stop(sd);
|
||||
session_device_notify(sd, SESSION_DEVICE_RELEASE);
|
||||
|
@ -440,7 +440,7 @@ static int deliver_fd(Manager *m, const char *fdname, int fd) {
|
||||
|
||||
static int manager_attach_fds(Manager *m) {
|
||||
_cleanup_strv_free_ char **fdnames = NULL;
|
||||
int n;
|
||||
int r, n;
|
||||
|
||||
/* Upon restart, PID1 will send us back all fds of session devices that we previously opened. Each
|
||||
* file descriptor is associated with a given session. The session ids are passed through FDNAMES. */
|
||||
@ -461,9 +461,11 @@ static int manager_attach_fds(Manager *m) {
|
||||
safe_close(fd);
|
||||
|
||||
/* Remove from fdstore as well */
|
||||
(void) sd_notifyf(false,
|
||||
"FDSTOREREMOVE=1\n"
|
||||
"FDNAME=%s", fdnames[i]);
|
||||
r = sd_notifyf(false,
|
||||
"FDSTOREREMOVE=1\n"
|
||||
"FDNAME=%s", fdnames[i]);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to remove file descriptor from the store, ignoring: %m");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -273,7 +273,7 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_call_method(bus, bus_machine_mgr, "ListMachines", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
@ -352,7 +352,7 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||
|
||||
assert(bus);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_call_method(bus, bus_machine_mgr, "ListImages", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
@ -705,7 +705,7 @@ static int show_machine(int argc, char *argv[], void *userdata) {
|
||||
|
||||
properties = !strstr(argv[0], "status");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (properties && argc <= 1) {
|
||||
|
||||
@ -1004,7 +1004,7 @@ static int show_image(int argc, char *argv[], void *userdata) {
|
||||
|
||||
properties = !strstr(argv[0], "status");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (argc <= 1) {
|
||||
|
||||
@ -2251,7 +2251,7 @@ static int list_transfers(int argc, char *argv[], void *userdata) {
|
||||
double progress;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_call_method(bus, bus_import_mgr, "ListTransfers", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
@ -2446,7 +2446,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("machinectl", "1", &link);
|
||||
if (r < 0)
|
||||
|
@ -6,14 +6,13 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bus-error.h"
|
||||
#include "bus-locator.h"
|
||||
#include "bus-log-control-api.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "daemon-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "discover-image.h"
|
||||
#include "fd-util.h"
|
||||
@ -352,17 +351,14 @@ static int run(int argc, char *argv[]) {
|
||||
return log_error_errno(r, "Failed to fully start up daemon: %m");
|
||||
|
||||
log_debug("systemd-machined running as pid "PID_FMT, getpid_cached());
|
||||
(void) sd_notify(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Processing requests...");
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
r = manager_run(m);
|
||||
|
||||
(void) sd_notify(false, NOTIFY_STOPPING);
|
||||
log_debug("systemd-machined stopped as pid "PID_FMT, getpid_cached());
|
||||
(void) sd_notify(false,
|
||||
"STOPPING=1\n"
|
||||
"STATUS=Shutting down...");
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -1432,7 +1432,7 @@ static int list_devices(void) {
|
||||
}
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = table_print(table, NULL);
|
||||
if (r < 0)
|
||||
|
@ -810,7 +810,7 @@ static int list_links(int argc, char *argv[], void *userdata) {
|
||||
if (c < 0)
|
||||
return c;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
table = table_new("idx", "link", "type", "operational", "setup");
|
||||
if (!table)
|
||||
@ -2394,7 +2394,7 @@ static int link_status(int argc, char *argv[], void *userdata) {
|
||||
return dump_link_description(strv_skip(argv, 1));
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_open_system(&bus);
|
||||
if (r < 0)
|
||||
@ -2493,7 +2493,7 @@ static int link_lldp_status(int argc, char *argv[], void *userdata) {
|
||||
if (c < 0)
|
||||
return c;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
table = table_new("link",
|
||||
"chassis id",
|
||||
|
@ -304,7 +304,7 @@ static int help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("systemd-nspawn", "1", &link);
|
||||
if (r < 0)
|
||||
@ -4205,6 +4205,7 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
|
||||
ssize_t n;
|
||||
pid_t inner_child_pid;
|
||||
_cleanup_strv_free_ char **tags = NULL;
|
||||
int r;
|
||||
|
||||
assert(userdata);
|
||||
|
||||
@ -4243,8 +4244,11 @@ static int nspawn_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t r
|
||||
if (!tags)
|
||||
return log_oom();
|
||||
|
||||
if (strv_find(tags, "READY=1"))
|
||||
(void) sd_notifyf(false, "READY=1\n");
|
||||
if (strv_find(tags, "READY=1")) {
|
||||
r = sd_notify(false, "READY=1\n");
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
}
|
||||
|
||||
p = strv_find_startswith(tags, "STATUS=");
|
||||
if (p)
|
||||
@ -5134,8 +5138,11 @@ static int run_container(
|
||||
(void) sd_notifyf(false,
|
||||
"STATUS=Container running.\n"
|
||||
"X_NSPAWN_LEADER_PID=" PID_FMT, *pid);
|
||||
if (!arg_notify_ready)
|
||||
(void) sd_notify(false, "READY=1\n");
|
||||
if (!arg_notify_ready) {
|
||||
r = sd_notify(false, "READY=1\n");
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
}
|
||||
|
||||
if (arg_kill_signal > 0) {
|
||||
/* Try to kill the init system on SIGINT or SIGTERM */
|
||||
|
@ -16,7 +16,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("oomctl", "1", &link);
|
||||
if (r < 0)
|
||||
@ -52,7 +52,7 @@ static int dump_state(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect system bus: %m");
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
|
@ -333,7 +333,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_cat) {
|
||||
printf("%s-- OS Release: --%s\n", ansi_highlight(), ansi_normal());
|
||||
@ -1093,7 +1093,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("portablectl", "1", &link);
|
||||
if (r < 0)
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "sd-daemon.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bus-log-control-api.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "daemon-util.h"
|
||||
#include "def.h"
|
||||
#include "main-func.h"
|
||||
#include "portabled-bus.h"
|
||||
@ -154,15 +154,13 @@ static int run(int argc, char *argv[]) {
|
||||
return log_error_errno(r, "Failed to fully start up daemon: %m");
|
||||
|
||||
log_debug("systemd-portabled running as pid " PID_FMT, getpid_cached());
|
||||
sd_notify(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Processing requests...");
|
||||
r = sd_notify(false, NOTIFY_READY);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
r = manager_run(m);
|
||||
|
||||
(void) sd_notify(false,
|
||||
"STOPPING=1\n"
|
||||
"STATUS=Shutting down...");
|
||||
(void) sd_notify(false, NOTIFY_STOPPING);
|
||||
log_debug("systemd-portabled stopped as pid " PID_FMT, getpid_cached());
|
||||
return r;
|
||||
}
|
||||
|
@ -1587,7 +1587,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get link data for %i: %s", ifindex, bus_error_message(&error, r));
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (mode == STATUS_DNS)
|
||||
return status_print_strv_ifindex(ifindex, name, link_info.dns_ex ?: link_info.dns);
|
||||
@ -1851,7 +1851,7 @@ static int status_global(sd_bus *bus, StatusMode mode, bool *empty_line) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get global data: %s", bus_error_message(&error, r));
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (mode == STATUS_DNS)
|
||||
return status_print_strv_global(global_info.dns_ex ?: global_info.dns);
|
||||
|
@ -317,7 +317,10 @@ static int run(int argc, char *argv[]) {
|
||||
if (!ready) {
|
||||
/* Notify manager that we are now finished with processing whatever was
|
||||
* queued */
|
||||
(void) sd_notify(false, "READY=1");
|
||||
r = sd_notify(false, "READY=1");
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
|
||||
ready = true;
|
||||
}
|
||||
|
||||
|
@ -2783,7 +2783,7 @@ int table_print_with_pager(
|
||||
* the table header and logs about any error. */
|
||||
|
||||
if (json_format_flags & (JSON_FORMAT_OFF|JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO))
|
||||
(void) pager_open(pager_flags);
|
||||
pager_open(pager_flags);
|
||||
|
||||
saved_header = t->header;
|
||||
t->header = show_header;
|
||||
|
@ -83,23 +83,23 @@ static int no_quit_on_interrupt(int exe_name_fd, const char *less_opts) {
|
||||
return r;
|
||||
}
|
||||
|
||||
int pager_open(PagerFlags flags) {
|
||||
void pager_open(PagerFlags flags) {
|
||||
_cleanup_close_pair_ int fd[2] = { -1, -1 }, exe_name_pipe[2] = { -1, -1 };
|
||||
_cleanup_strv_free_ char **pager_args = NULL;
|
||||
const char *pager, *less_opts;
|
||||
int r;
|
||||
|
||||
if (flags & PAGER_DISABLE)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
if (pager_pid > 0)
|
||||
return 1;
|
||||
return;
|
||||
|
||||
if (terminal_is_dumb())
|
||||
return 0;
|
||||
return;
|
||||
|
||||
if (!is_main_thread())
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EPERM), "Pager invoked from wrong thread.");
|
||||
return (void) log_error_errno(SYNTHETIC_ERRNO(EPERM), "Pager invoked from wrong thread.");
|
||||
|
||||
pager = getenv("SYSTEMD_PAGER");
|
||||
if (!pager)
|
||||
@ -108,11 +108,11 @@ int pager_open(PagerFlags flags) {
|
||||
if (pager) {
|
||||
pager_args = strv_split(pager, WHITESPACE);
|
||||
if (!pager_args)
|
||||
return log_oom();
|
||||
return (void) log_oom();
|
||||
|
||||
/* If the pager is explicitly turned off, honour it */
|
||||
if (strv_isempty(pager_args) || strv_equal(pager_args, STRV_MAKE("cat")))
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Determine and cache number of columns/lines before we spawn the pager so that we get the value from the
|
||||
@ -121,11 +121,11 @@ int pager_open(PagerFlags flags) {
|
||||
(void) lines();
|
||||
|
||||
if (pipe2(fd, O_CLOEXEC) < 0)
|
||||
return log_error_errno(errno, "Failed to create pager pipe: %m");
|
||||
return (void) log_error_errno(errno, "Failed to create pager pipe: %m");
|
||||
|
||||
/* This is a pipe to feed the name of the executed pager binary into the parent */
|
||||
if (pipe2(exe_name_pipe, O_CLOEXEC) < 0)
|
||||
return log_error_errno(errno, "Failed to create exe_name pipe: %m");
|
||||
return (void) log_error_errno(errno, "Failed to create exe_name pipe: %m");
|
||||
|
||||
/* Initialize a good set of less options */
|
||||
less_opts = getenv("SYSTEMD_LESS");
|
||||
@ -137,7 +137,7 @@ int pager_open(PagerFlags flags) {
|
||||
/* We set SIGINT as PR_DEATHSIG signal here, to match the "K" parameter we set in $LESS, which enables SIGINT behaviour. */
|
||||
r = safe_fork("(pager)", FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGINT|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pager_pid);
|
||||
if (r < 0)
|
||||
return r;
|
||||
return;
|
||||
if (r == 0) {
|
||||
const char *less_charset, *exe;
|
||||
|
||||
@ -245,26 +245,22 @@ int pager_open(PagerFlags flags) {
|
||||
stored_stdout = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, 3);
|
||||
if (dup2(fd[1], STDOUT_FILENO) < 0) {
|
||||
stored_stdout = safe_close(stored_stdout);
|
||||
return log_error_errno(errno, "Failed to duplicate pager pipe: %m");
|
||||
return (void) log_error_errno(errno, "Failed to duplicate pager pipe: %m");
|
||||
}
|
||||
stdout_redirected = true;
|
||||
|
||||
stored_stderr = fcntl(STDERR_FILENO, F_DUPFD_CLOEXEC, 3);
|
||||
if (dup2(fd[1], STDERR_FILENO) < 0) {
|
||||
stored_stderr = safe_close(stored_stderr);
|
||||
return log_error_errno(errno, "Failed to duplicate pager pipe: %m");
|
||||
return (void) log_error_errno(errno, "Failed to duplicate pager pipe: %m");
|
||||
}
|
||||
stderr_redirected = true;
|
||||
|
||||
exe_name_pipe[1] = safe_close(exe_name_pipe[1]);
|
||||
|
||||
r = no_quit_on_interrupt(TAKE_FD(exe_name_pipe[0]), less_opts);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0)
|
||||
(void) ignore_signals(SIGINT);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void pager_close(void) {
|
||||
|
@ -10,7 +10,7 @@ typedef enum PagerFlags {
|
||||
PAGER_JUMP_TO_END = 1 << 1,
|
||||
} PagerFlags;
|
||||
|
||||
int pager_open(PagerFlags flags);
|
||||
void pager_open(PagerFlags flags);
|
||||
void pager_close(void);
|
||||
bool pager_have(void) _pure_;
|
||||
|
||||
|
@ -410,7 +410,7 @@ static int run(int argc, char *argv[]) {
|
||||
return log_error_errno(r, "Failed to enumerate sysctl.d files: %m");
|
||||
|
||||
if (arg_cat_config) {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return cat_files(NULL, files, 0);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ int cat(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
STRV_FOREACH(name, names) {
|
||||
_cleanup_free_ char *fragment_path = NULL;
|
||||
|
@ -157,7 +157,7 @@ int list_dependencies(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(r, "Failed to expand names: %m");
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
STRV_FOREACH(u, units) {
|
||||
if (u != units)
|
||||
|
@ -73,7 +73,7 @@ static int output_jobs_list(sd_bus *bus, const struct job_info* jobs, unsigned n
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
table = table_new("job", "unit", "type", "state");
|
||||
if (!table)
|
||||
@ -168,7 +168,7 @@ int list_jobs(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return output_jobs_list(bus, jobs, c, skipped);
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ int list_machines(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
typesafe_qsort(machine_infos, r, compare_machine_info);
|
||||
rc = output_machines_list(machine_infos, r);
|
||||
|
@ -255,7 +255,7 @@ int list_unit_files(int argc, char *argv[], void *userdata) {
|
||||
return bus_log_parse_error(r);
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
typesafe_qsort(units, c, compare_unit_file_list);
|
||||
r = output_unit_file_list(units, c);
|
||||
|
@ -221,7 +221,7 @@ int list_units(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
if (arg_with_dependencies) {
|
||||
_cleanup_strv_free_ char **names = NULL;
|
||||
@ -439,7 +439,7 @@ int list_sockets(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = expand_unit_names(bus, strv_skip(argv, 1), ".socket", &sockets_with_suffix, NULL);
|
||||
if (r < 0)
|
||||
@ -703,7 +703,7 @@ int list_timers(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = expand_unit_names(bus, strv_skip(argv, 1), ".timer", &timers_with_suffix, NULL);
|
||||
if (r < 0)
|
||||
|
@ -36,7 +36,7 @@ int show_environment(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = bus_get_property(bus, bus_systemd_mgr, "Environment", &error, &reply, "as");
|
||||
if (r < 0)
|
||||
|
@ -2036,7 +2036,7 @@ static int show_all(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
c = (unsigned) r;
|
||||
|
||||
@ -2142,7 +2142,7 @@ int show(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
/* If no argument is specified inspect the manager itself */
|
||||
if (show_mode == SYSTEMCTL_SHOW_PROPERTIES && argc <= 1)
|
||||
|
@ -128,7 +128,7 @@ static int systemctl_help(void) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("systemctl", "1", &link);
|
||||
if (r < 0)
|
||||
|
@ -1807,7 +1807,7 @@ static int cat_config(void) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return cat_files(NULL, files, 0);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ static int list_timezones(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
strv_print(zones);
|
||||
|
||||
return 0;
|
||||
|
@ -915,7 +915,7 @@ void manager_disconnect(Manager *m) {
|
||||
|
||||
m->event_timeout = sd_event_source_unref(m->event_timeout);
|
||||
|
||||
sd_notifyf(false, "STATUS=Idle.");
|
||||
sd_notify(false, "STATUS=Idle.");
|
||||
}
|
||||
|
||||
void manager_flush_server_names(Manager *m, ServerType t) {
|
||||
|
@ -3754,7 +3754,7 @@ static int run(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
if (arg_cat_config) {
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
return cat_config(config_dirs, argv + optind);
|
||||
}
|
||||
|
@ -315,9 +315,18 @@ static void manager_exit(Manager *manager) {
|
||||
manager_kill_workers(manager, true);
|
||||
}
|
||||
|
||||
static void notify_ready(void) {
|
||||
int r;
|
||||
|
||||
r = sd_notifyf(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Processing with %u children at max", arg_children_max);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
|
||||
}
|
||||
|
||||
/* reload requested, HUP signal received, rules changed, builtin changed */
|
||||
static void manager_reload(Manager *manager) {
|
||||
|
||||
assert(manager);
|
||||
|
||||
sd_notify(false,
|
||||
@ -328,9 +337,7 @@ static void manager_reload(Manager *manager) {
|
||||
manager->rules = udev_rules_free(manager->rules);
|
||||
udev_builtin_exit();
|
||||
|
||||
sd_notifyf(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Processing with %u children at max", arg_children_max);
|
||||
notify_ready();
|
||||
}
|
||||
|
||||
static int on_kill_workers_event(sd_event_source *s, uint64_t usec, void *userdata) {
|
||||
@ -1199,9 +1206,7 @@ static int on_ctrl_msg(UdevCtrl *uctrl, UdevCtrlMessageType type, const UdevCtrl
|
||||
log_debug("Received udev control message (SET_MAX_CHILDREN), setting children_max=%i", value->intval);
|
||||
arg_children_max = value->intval;
|
||||
|
||||
(void) sd_notifyf(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Processing with %u children at max", arg_children_max);
|
||||
notify_ready();
|
||||
break;
|
||||
case UDEV_CTRL_PING:
|
||||
log_debug("Received udev control message (PING)");
|
||||
@ -1862,9 +1867,7 @@ static int main_loop(Manager *manager) {
|
||||
if (r < 0)
|
||||
log_error_errno(r, "Failed to apply permissions on static device nodes: %m");
|
||||
|
||||
(void) sd_notifyf(false,
|
||||
"READY=1\n"
|
||||
"STATUS=Processing with %u children at max", arg_children_max);
|
||||
notify_ready();
|
||||
|
||||
r = sd_event_loop(manager->event);
|
||||
if (r < 0)
|
||||
|
@ -574,7 +574,7 @@ static int help(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_free_ char *link = NULL;
|
||||
int r;
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
pager_open(arg_pager_flags);
|
||||
|
||||
r = terminal_urlify_man("userdbctl", "1", &link);
|
||||
if (r < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user