process-util: move namespace_get_leader() to namespace-util

This allows us to drop the hack for recursive includes.
This commit is contained in:
Mike Yuan
2025-01-04 17:08:00 +01:00
parent 0577339d7d
commit a33f691374
4 changed files with 32 additions and 34 deletions
-27
View File
@@ -395,33 +395,6 @@ int container_get_leader(const char *machine, pid_t *pid) {
return 0;
}
int namespace_get_leader(pid_t pid, NamespaceType type, pid_t *ret) {
int r;
assert(ret);
for (;;) {
pid_t ppid;
r = get_process_ppid(pid, &ppid);
if (r < 0)
return r;
r = in_same_namespace(pid, ppid, type);
if (r < 0)
return r;
if (r == 0) {
/* If the parent and the child are not in the same
* namespace, then the child is the leader we are
* looking for. */
*ret = pid;
return 0;
}
pid = ppid;
}
}
int pid_is_kernel_thread(pid_t pid) {
_cleanup_free_ char *line = NULL;
unsigned long long flags;