be52b9f
From 184c94de2cd85228b729dac1fb5f59453cfbbbed Mon Sep 17 00:00:00 2001
be52b9f
From: Ross Lagerwall <rosslagerwall@gmail.com>
be52b9f
Date: Sun, 9 Jun 2013 17:28:44 +0100
51b11df
Subject: [PATCH] service: don't report alien child as alive when it's not
be52b9f
be52b9f
When a sigchld is received from an alien child, main_pid is set to
be52b9f
0 then service_enter_running calls main_pid_good to check if the
be52b9f
child is running.  This incorrectly returned true because
be52b9f
kill(main_pid, 0) would return >= 0.
be52b9f
be52b9f
This fixes an error where a service would die and the cgroup would
be52b9f
become empty but the service would still report as active (running).
be52b9f
---
be52b9f
 src/core/service.c | 2 +-
be52b9f
 1 file changed, 1 insertion(+), 1 deletion(-)
be52b9f
be52b9f
diff --git a/src/core/service.c b/src/core/service.c
be52b9f
index e110a41..973bd03 100644
be52b9f
--- a/src/core/service.c
be52b9f
+++ b/src/core/service.c
be52b9f
@@ -1865,7 +1865,7 @@ static int main_pid_good(Service *s) {
be52b9f
 
be52b9f
                 /* If it's an alien child let's check if it is still
be52b9f
                  * alive ... */
be52b9f
-                if (s->main_pid_alien)
be52b9f
+                if (s->main_pid_alien && s->main_pid > 0)
be52b9f
                         return kill(s->main_pid, 0) >= 0 || errno != ESRCH;
be52b9f
 
be52b9f
                 /* .. otherwise assume we'll get a SIGCHLD for it,
be52b9f
-- 
51b11df
1.8.2.562.g931e949
be52b9f