summaryrefslogtreecommitdiff
path: root/src/portable/portabled.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/portable/portabled.c')
-rw-r--r--src/portable/portabled.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/portable/portabled.c b/src/portable/portabled.c
index 53faa09bac..63fc340469 100644
--- a/src/portable/portabled.c
+++ b/src/portable/portabled.c
@@ -6,6 +6,7 @@
#include "alloc-util.h"
#include "bus-util.h"
#include "def.h"
+#include "main-func.h"
#include "portabled-bus.h"
#include "portabled-image-bus.h"
#include "portabled.h"
@@ -46,7 +47,7 @@ static int manager_new(Manager **ret) {
static Manager* manager_unref(Manager *m) {
assert(m);
- hashmap_free_with_destructor(m->image_cache, image_unref);
+ hashmap_free(m->image_cache);
sd_event_source_unref(m->image_cache_defer_event);
@@ -122,47 +123,41 @@ static int manager_run(Manager *m) {
check_idle, m);
}
-int main(int argc, char *argv[]) {
+static int run(int argc, char *argv[]) {
_cleanup_(manager_unrefp) Manager *m = NULL;
int r;
- log_set_target(LOG_TARGET_AUTO);
- log_parse_environment();
- log_open();
+ log_setup_service();
umask(0022);
if (argc != 1) {
log_error("This program takes no arguments.");
- r = -EINVAL;
- goto finish;
+ return -EINVAL;
}
assert_se(sigprocmask_many(SIG_BLOCK, NULL, SIGCHLD, SIGTERM, SIGINT, -1) >= 0);
r = manager_new(&m);
- if (r < 0) {
- log_error_errno(r, "Failed to allocate manager object: %m");
- goto finish;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to allocate manager object: %m");
r = manager_startup(m);
- if (r < 0) {
- log_error_errno(r, "Failed to fully start up daemon: %m");
- goto finish;
- }
+ if (r < 0)
+ 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 = manager_run(m);
+ (void) sd_notify(false,
+ "STOPPING=1\n"
+ "STATUS=Shutting down...");
log_debug("systemd-portabled stopped as pid " PID_FMT, getpid_cached());
-
-finish:
- return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
-
+ return r;
}
+
+DEFINE_MAIN_FUNCTION(run);