diff options
author | Lennart Poettering <lennart@poettering.net> | 2023-10-16 16:13:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-16 16:13:16 +0200 |
commit | cde8cc946be9183c8381a5d30be0a862abd6b389 (patch) | |
tree | b6f5d178333e3d68f75bef09463fb39b157be916 /src/basic/process-util.c | |
parent | mount-util: use mount beneath to replace previous namespace mount (diff) | |
parent | nspawn: set CoredumpReceive=yes on container's scope when --boot is set (diff) | |
download | systemd-cde8cc946be9183c8381a5d30be0a862abd6b389.tar.xz systemd-cde8cc946be9183c8381a5d30be0a862abd6b389.zip |
Merge pull request #29272 from enr0n/coredump-container
coredump: support forwarding coredumps to containers
Diffstat (limited to 'src/basic/process-util.c')
-rw-r--r-- | src/basic/process-util.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/basic/process-util.c b/src/basic/process-util.c index d0ffb2d614..ed096900ac 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -319,6 +319,33 @@ 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 is_kernel_thread(pid_t pid) { _cleanup_free_ char *line = NULL; unsigned long long flags; |