process-util: add pidref_is_my_child()

This commit is contained in:
Lennart Poettering
2023-10-18 14:49:40 +02:00
parent becdfcb9f1
commit 6774be4206
4 changed files with 29 additions and 3 deletions
+20
View File
@@ -1015,6 +1015,9 @@ int pid_is_my_child(pid_t pid) {
pid_t ppid;
int r;
if (pid < 0)
return -ESRCH;
if (pid <= 1)
return false;
@@ -1025,6 +1028,23 @@ int pid_is_my_child(pid_t pid) {
return ppid == getpid_cached();
}
int pidref_is_my_child(const PidRef *pid) {
int r, result;
if (!pidref_is_set(pid))
return -ESRCH;
result = pid_is_my_child(pid->pid);
if (result < 0)
return result;
r = pidref_verify(pid);
if (r < 0)
return r;
return result;
}
bool pid_is_unwaited(pid_t pid) {
/* Checks whether a PID is still valid at all, including a zombie */