diff --git a/server/start_systemd_unit.cpp b/server/start_systemd_unit.cpp index e1e9353a..90955c22 100644 --- a/server/start_systemd_unit.cpp +++ b/server/start_systemd_unit.cpp @@ -162,9 +162,11 @@ void systemd_units_manager::on_unit_result( void * self_) { auto self = (systemd_units_manager *)(self_); - std::string_view state = unit_unit_get_active_state(unit); + const char * state = unit_unit_get_active_state(unit); + if (state == nullptr) + return; bool empty = self->units.empty(); - if (state == "inactive" or state == "failed") + if (state == std::string_view("inactive") or state == std::string_view("failed")) std::erase_if(self->units, [&](auto & o) { return o.get() == unit; }); if (self->state_changed_cb and self->units.empty() and not empty) self->state_changed_cb();