// Initialize all sources
r = td_sources_create(&self->sources, self->ctx, self, self->enabled_sources);
if (r < 0)
- return r;
+ goto ERROR;
// Initialize all graphs
r = td_graphs_create(&self->graphs, self->ctx, self);
if (r < 0)
- return r;
+ goto ERROR;
#ifdef HAVE_SENSORS
// Initialize sensors
r = td_sensors_init(self->ctx);
if (r < 0)
- return r;
+ goto ERROR;
#endif /* HAVE_SENSORS */
return 0;
+
+ERROR:
+ ERROR(self->ctx, "Failed to initialize: %s\n", strerror(-r));
+
+ // Terminating the event loop
+ return sd_event_exit(sd_event_source_get_event(source), r);
}
static int td_daemon_on_exit(sd_event_source* source, void* data) {