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.
This commit is contained in:
Lennart Poettering
2013-12-18 18:21:27 +01:00
parent f6613dd959
commit bf108e5541
3 changed files with 60 additions and 48 deletions
+10
View File
@@ -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;
}
+2
View File
@@ -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);