_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+ char *u;
int r;
r = sd_bus_call_method(
return r;
}
- r = sd_bus_message_read(reply, "o", unit);
+ r = sd_bus_message_read(reply, "o", &u);
if (r < 0)
return bus_log_parse_error(r);
+ u = strdup(u);
+ if (!u)
+ return log_oom();
+
+ *unit = u;
return 0;
}
} else {
/* Interpret as PID */
r = get_unit_dbus_path_by_pid(bus, id, &unit);
- if (r < 0)
+ if (r < 0) {
ret = r;
+ continue;
+ }
}
show_one(args[0], bus, unit, show_properties, &new_line, &ellipsized);