summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-18 04:19:20 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-18 18:21:27 +0100
commitbf108e5541e2a3cbc6f0c59e93665eceb7a5ce05 (patch)
tree9cf3647427c0b9fb99a05b0fc48eedd0c0256015 /src/shared/util.c
parentf6613dd959a1ab49bf061555ada77903397569ad (diff)
service: watch main pid even in final states
In some circumstances, for example when start-up times out we immediately jump into the final state, at which point we still should try to watch the main pid so that the SIGCHLD allows us to quickly move into dead state.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c10
1 files changed, 10 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;
+}