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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user