summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c10
-rw-r--r--src/shared/util.h2
2 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 2cf9fbe53e..f59897105a 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6088,3 +6088,13 @@ int namespace_enter(int pidns_fd, int mntns_fd, int root_fd) {
return 0;
}
+
+bool pid_valid(pid_t pid) {
+ if (pid <= 0)
+ return false;
+
+ if (kill(pid, 0) >= 0)
+ return true;
+
+ return errno != ESRCH;
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index ddb35181ab..3e0a6d5c1c 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -804,3 +804,5 @@ int container_get_leader(const char *machine, pid_t *pid);
int namespace_open(pid_t pid, int *pidns_fd, int *mntns_fd, int *root_fd);
int namespace_enter(int pidns_fd, int mntns_fd, int root_fd);
+
+bool pid_valid(pid_t pid);