launch/service: use CollectMode=inactive-or-failed
When launching transient units, we want failed units to be garbage
collected immediately. All relevant information is retained in the logs
and further activations of the same unit will increment an instance
counter, and thus use a different unit name.
Suggested-by: Benjamin Berg
@@ -688,6 +688,34 @@ static int service_start_transient_unit(Service *service) {
return error_origin(r);
}
+ r = sd_bus_message_close_container(method_call);
+ if (r < 0)
+ return error_origin(r);
+
+ r = sd_bus_message_open_container(method_call, 'r', "sv");
+ if (r < 0)
+ return error_origin(r);
+
+ {
+ r = sd_bus_message_append(method_call, "s", "CollectMode");
+ if (r < 0)
+ return error_origin(r);
+
+ r = sd_bus_message_open_container(method_call, 'v', "s");
+ if (r < 0)
+ return error_origin(r);
+
+ {
+ r = sd_bus_message_append(method_call, "s", "inactive-or-failed");
+ if (r < 0)
+ return error_origin(r);
+ }
+
+ r = sd_bus_message_close_container(method_call);
+ if (r < 0)
+ return error_origin(r);
+ }
+
r = sd_bus_message_close_container(method_call);
if (r < 0)
return error_origin(r);
