summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 4f3145b2bc..72b1e2f3c8 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6045,7 +6045,9 @@ int namespace_enter(int pidns_fd, int mntns_fd, int root_fd) {
return 0;
}
-bool pid_valid(pid_t pid) {
+bool pid_is_unwaited(pid_t pid) {
+ /* Checks whether a PID is still valid at all, including a zombie */
+
if (pid <= 0)
return false;
@@ -6055,6 +6057,21 @@ bool pid_valid(pid_t pid) {
return errno != ESRCH;
}
+bool pid_is_alive(pid_t pid) {
+ int r;
+
+ /* Checks whether a PID is still valid and not a zombie */
+
+ if (pid <= 0)
+ return false;
+
+ r = get_process_state(pid);
+ if (r == -ENOENT || r == 'Z')
+ return false;
+
+ return true;
+}
+
int getpeercred(int fd, struct ucred *ucred) {
socklen_t n = sizeof(struct ucred);
struct ucred u;