mirror of
https://github.com/systemd/systemd.git
synced 2024-12-22 17:35:35 +03:00
Merge pull request #29454 from poettering/cg-pidref-get-path
cgroup-util: add cg_pidref_get_path() helper and use it
This commit is contained in:
commit
c6711da087
1
TODO
1
TODO
@ -209,7 +209,6 @@ Features:
|
|||||||
- pid_is_alive() → pidref_is_alive()
|
- pid_is_alive() → pidref_is_alive()
|
||||||
- is_kernel_thread() → pidref_is_kernel_thread()
|
- is_kernel_thread() → pidref_is_kernel_thread()
|
||||||
- pid_is_my_child() → pidref_is_my_child()
|
- pid_is_my_child() → pidref_is_my_child()
|
||||||
- cg_pid_get_path() → cg_pidref_get_path()
|
|
||||||
- get_process_uid() → pidref_get_uid()
|
- get_process_uid() → pidref_get_uid()
|
||||||
- actually wait for POLLIN on pidref's pidfd in service logic
|
- actually wait for POLLIN on pidref's pidfd in service logic
|
||||||
- exec_spawn()
|
- exec_spawn()
|
||||||
|
@ -809,6 +809,28 @@ int cg_pid_get_path(const char *controller, pid_t pid, char **ret_path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cg_pidref_get_path(const char *controller, PidRef *pidref, char **ret_path) {
|
||||||
|
_cleanup_free_ char *path = NULL;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
assert(ret_path);
|
||||||
|
|
||||||
|
if (!pidref_is_set(pidref))
|
||||||
|
return -ESRCH;
|
||||||
|
|
||||||
|
r = cg_pid_get_path(controller, pidref->pid, &path);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
/* Before we return the path, make sure the procfs entry for this pid still matches the pidref */
|
||||||
|
r = pidref_verify(pidref);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
|
*ret_path = TAKE_PTR(path);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int cg_install_release_agent(const char *controller, const char *agent) {
|
int cg_install_release_agent(const char *controller, const char *agent) {
|
||||||
_cleanup_free_ char *fs = NULL, *contents = NULL;
|
_cleanup_free_ char *fs = NULL, *contents = NULL;
|
||||||
const char *sc;
|
const char *sc;
|
||||||
|
@ -204,6 +204,7 @@ int cg_get_path(const char *controller, const char *path, const char *suffix, ch
|
|||||||
int cg_get_path_and_check(const char *controller, const char *path, const char *suffix, char **fs);
|
int cg_get_path_and_check(const char *controller, const char *path, const char *suffix, char **fs);
|
||||||
|
|
||||||
int cg_pid_get_path(const char *controller, pid_t pid, char **path);
|
int cg_pid_get_path(const char *controller, pid_t pid, char **path);
|
||||||
|
int cg_pidref_get_path(const char *controller, PidRef *pidref, char **path);
|
||||||
|
|
||||||
int cg_rmdir(const char *controller, const char *path);
|
int cg_rmdir(const char *controller, const char *path);
|
||||||
|
|
||||||
|
@ -3784,10 +3784,7 @@ Unit *manager_get_unit_by_pidref_cgroup(Manager *m, PidRef *pid) {
|
|||||||
|
|
||||||
assert(m);
|
assert(m);
|
||||||
|
|
||||||
if (!pidref_is_set(pid))
|
if (cg_pidref_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &cgroup) < 0)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid->pid, &cgroup) < 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return manager_get_unit_by_cgroup(m, cgroup);
|
return manager_get_unit_by_cgroup(m, cgroup);
|
||||||
|
Loading…
Reference in New Issue
Block a user