service: don't report alien child as alive when it's not

When a sigchld is received from an alien child, main_pid is set to
0 then service_enter_running calls main_pid_good to check if the
child is running.  This incorrectly returned true because
kill(main_pid, 0) would return >= 0.

This fixes an error where a service would die and the cgroup would
become empty but the service would still report as active (running).
This commit is contained in:
Ross Lagerwall
2013-06-09 18:26:41 -04:00
committed by Zbigniew Jędrzejewski-Szmek
parent 7085053a43
commit 62220cf70e
+1 -1
View File
@@ -1865,7 +1865,7 @@ static int main_pid_good(Service *s) {
/* If it's an alien child let's check if it is still
* alive ... */
if (s->main_pid_alien)
if (s->main_pid_alien && s->main_pid > 0)
return kill(s->main_pid, 0) >= 0 || errno != ESRCH;
/* .. otherwise assume we'll get a SIGCHLD for it,