mirror of
https://github.com/systemd/systemd.git
synced 2025-02-28 05:57:33 +03:00
cgroup-util: introduce cg_pidref_get_unit
This commit is contained in:
parent
620788da17
commit
2c302e8919
@ -1262,6 +1262,27 @@ int cg_pid_get_unit(pid_t pid, char **ret_unit) {
|
||||
return cg_path_get_unit(cgroup, ret_unit);
|
||||
}
|
||||
|
||||
int cg_pidref_get_unit(const PidRef *pidref, char **ret) {
|
||||
_cleanup_free_ char *unit = NULL;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (!pidref_is_set(pidref))
|
||||
return -ESRCH;
|
||||
|
||||
r = cg_pid_get_unit(pidref->pid, &unit);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = pidref_verify(pidref);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = TAKE_PTR(unit);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Skip session-*.scope, but require it to be there.
|
||||
*/
|
||||
|
@ -279,6 +279,7 @@ int cg_pid_get_path_shifted(pid_t pid, const char *cached_root, char **ret_cgrou
|
||||
int cg_pid_get_session(pid_t pid, char **ret_session);
|
||||
int cg_pid_get_owner_uid(pid_t pid, uid_t *ret_uid);
|
||||
int cg_pid_get_unit(pid_t pid, char **ret_unit);
|
||||
int cg_pidref_get_unit(const PidRef *pidref, char **ret);
|
||||
int cg_pid_get_user_unit(pid_t pid, char **ret_unit);
|
||||
int cg_pid_get_machine_name(pid_t pid, char **ret_machine);
|
||||
int cg_pid_get_slice(pid_t pid, char **ret_slice);
|
||||
|
Loading…
x
Reference in New Issue
Block a user