_cleanup_free_ UnitInfo *unit_infos = NULL;
if (!bus)
- return log_error_errno(ENOTSUP, "Unit name globbing without bus is not implemented.");
+ return log_error_errno(EOPNOTSUPP, "Unit name globbing without bus is not implemented.");
r = get_unit_list(bus, NULL, globs, &unit_infos, 0, &reply);
if (r < 0)
a == ACTION_HIBERNATE ||
a == ACTION_HYBRID_SLEEP)) {
r = reboot_with_logind(bus, a);
- if (r >= 0 || IN_SET(r, -ENOTSUP, -EINPROGRESS))
+ if (r >= 0 || IN_SET(r, -EOPNOTSUPP, -EINPROGRESS))
return r;
}
/* CGroup */
uint64_t memory_current;
uint64_t memory_limit;
+ uint64_t cpu_usage_nsec;
LIST_HEAD(ExecStatusInfo, exec);
} UnitStatusInfo;
printf("\n");
}
+ if (i->cpu_usage_nsec != (uint64_t) -1) {
+ char buf[FORMAT_TIMESPAN_MAX];
+ printf(" CPU: %s\n", format_timespan(buf, sizeof(buf), i->cpu_usage_nsec / NSEC_PER_USEC, USEC_PER_MSEC));
+ }
+
if (i->control_group &&
(i->main_pid > 0 || i->control_pid > 0 ||
((arg_transport != BUS_TRANSPORT_LOCAL && arg_transport != BUS_TRANSPORT_MACHINE) || cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, i->control_group, false) == 0))) {
i->memory_current = u;
else if (streq(name, "MemoryLimit"))
i->memory_limit = u;
+ else if (streq(name, "CPUUsageNSec"))
+ i->cpu_usage_nsec = u;
break;
}
UnitStatusInfo info = {
.memory_current = (uint64_t) -1,
.memory_limit = (uint64_t) -1,
+ .cpu_usage_nsec = (uint64_t) -1,
};
ExecStatusInfo *p;
int r;
_cleanup_strv_free_ char **names = NULL;
char **name;
bool first = true, avoid_bus_cache;
- int r = 0;
+ int r;
assert(args);
}
}
- return r < 0 ? r : 0;
+ return 0;
}
static int set_property(sd_bus *bus, char **args) {
static int enable_sysv_units(const char *verb, char **args) {
int r = 0;
-#if defined(HAVE_SYSV_COMPAT) && defined(HAVE_CHKCONFIG)
- unsigned f = 0;
- _cleanup_lookup_paths_free_ LookupPaths paths = {};
-
- if (arg_scope != UNIT_FILE_SYSTEM)
- return 0;
-
- if (!streq(verb, "enable") &&
- !streq(verb, "disable") &&
- !streq(verb, "is-enabled"))
- return 0;
-
- /* Processes all SysV units, and reshuffles the array so that
- * afterwards only the native units remain */
-
- r = lookup_paths_init(&paths, SYSTEMD_SYSTEM, false, arg_root, NULL, NULL, NULL);
- if (r < 0)
- return r;
-
- r = 0;
- while (args[f]) {
- const char *name;
- _cleanup_free_ char *p = NULL, *q = NULL, *l = NULL;
- bool found_native = false, found_sysv;
- unsigned c = 1;
- const char *argv[6] = { "/sbin/chkconfig", NULL, NULL, NULL, NULL };
- char **k;
- int j;
- pid_t pid;
- siginfo_t status;
-
- name = args[f++];
-
- if (!endswith(name, ".service"))
- continue;
-
- if (path_is_absolute(name))
- continue;
-
- STRV_FOREACH(k, paths.unit_path) {
- _cleanup_free_ char *path = NULL;
-
- path = path_join(arg_root, *k, name);
- if (!path)
- return log_oom();
-
- found_native = access(path, F_OK) >= 0;
- if (found_native)
- break;
- }
-
- if (found_native)
- continue;
-
- p = path_join(arg_root, SYSTEM_SYSVINIT_PATH, name);
- if (!p)
- return log_oom();
-
- p[strlen(p) - strlen(".service")] = 0;
- found_sysv = access(p, F_OK) >= 0;
- if (!found_sysv)
- continue;
-
- log_info("%s is not a native service, redirecting to /sbin/chkconfig.", name);
-
- if (!isempty(arg_root))
- argv[c++] = q = strappend("--root=", arg_root);
-
- argv[c++] = basename(p);
- argv[c++] =
- streq(verb, "enable") ? "on" :
- streq(verb, "disable") ? "off" : "--level=5";
- argv[c] = NULL;
-
- l = strv_join((char**)argv, " ");
- if (!l)
- return log_oom();
-
- log_info("Executing %s", l);
-
- pid = fork();
- if (pid < 0)
- return log_error_errno(errno, "Failed to fork: %m");
- else if (pid == 0) {
- /* Child */
-
- execv(argv[0], (char**) argv);
- _exit(EXIT_FAILURE);
- }
-
- j = wait_for_terminate(pid, &status);
- if (j < 0) {
- log_error_errno(r, "Failed to wait for child: %m");
- return j;
- }
-
- if (status.si_code == CLD_EXITED) {
- if (streq(verb, "is-enabled")) {
- if (status.si_status == 0) {
- if (!arg_quiet)
- puts("enabled");
- r = 1;
- } else {
- if (!arg_quiet)
- puts("disabled");
- }
-
- } else if (status.si_status != 0)
- return -EINVAL;
- } else
- return -EPROTO;
-
- /* Remove this entry, so that we don't try enabling it as native unit */
- assert(f > 0);
- f--;
- assert(args[f] == name);
- strv_remove(args, name);
- }
-
-#endif
return r;
}