]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/systemctl/systemctl-daemon-reload.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
4 #include "bus-locator.h"
5 #include "systemctl-daemon-reload.h"
6 #include "systemctl-util.h"
9 int daemon_reload(int argc
, char *argv
[], void *userdata
) {
10 _cleanup_(sd_bus_error_free
) sd_bus_error error
= SD_BUS_ERROR_NULL
;
11 _cleanup_(sd_bus_message_unrefp
) sd_bus_message
*m
= NULL
;
16 r
= acquire_bus(BUS_MANAGER
, &bus
);
20 polkit_agent_open_maybe();
32 case ACTION_SYSTEMCTL
:
33 method
= streq(argv
[0], "daemon-reexec") ? "Reexecute" :
34 /* "daemon-reload" */ "Reload";
38 assert_not_reached("Unexpected action");
41 r
= bus_message_new_method_call(bus
, &m
, bus_systemd_mgr
, method
);
43 return bus_log_create_error(r
);
45 /* Note we use an extra-long timeout here. This is because a reload or reexec means generators are
46 * rerun which are timed out after DEFAULT_TIMEOUT_USEC. Let's use twice that time here, so that the
47 * generators can have their timeout, and for everything else there's the same time budget in
50 r
= sd_bus_call(bus
, m
, DEFAULT_TIMEOUT_USEC
* 2, &error
, NULL
);
52 /* On reexecution, we expect a disconnect, not a reply */
53 if (IN_SET(r
, -ETIMEDOUT
, -ECONNRESET
) && streq(method
, "Reexecute"))
56 if (r
< 0 && arg_action
== ACTION_SYSTEMCTL
)
57 return log_error_errno(r
, "Failed to reload daemon: %s", bus_error_message(&error
, r
));
59 /* Note that for the legacy commands (i.e. those with action != ACTION_SYSTEMCTL) we support
60 * fallbacks to the old ways of doing things, hence don't log any error in that case here. */