<p dir="ltr">Sorry, I sent the wrong patch</p>
<div class="gmail_quote">2014-2-15 ÉÏÎç2:34ÓÚ "Yuxuan Shui" <<a href="mailto:yshuiv7@gmail.com">yshuiv7@gmail.com</a>>дµÀ£º<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Commit 5ba6985b moves the UNIT_VTABLE(u)->sigchld_event before systemd<br>
actually reap the zombie. Which leads to service_load_pid_file accept<br>
zombie as a valid pid.<br>
---<br>
 src/core/service.c |  3 +++<br>
 src/shared/util.c  | 24 ++++++++++++++++++++++++<br>
 src/shared/util.h  |  1 +<br>
 3 files changed, 28 insertions(+)<br>
<br>
diff --git a/src/core/service.c b/src/core/service.c<br>
index 5129784..64a0670 100644<br>
--- a/src/core/service.c<br>
+++ b/src/core/service.c<br>
@@ -1376,6 +1376,9 @@ static int service_load_pid_file(Service *s, bool may_warn) {<br>
                 return -ESRCH;<br>
         }<br>
<br>
+        if ('Z' == get_process_state(pid))<br>
+                return -ESRCH;<br>
+<br>
         if (s->main_pid_known) {<br>
                 if (pid == s->main_pid)<br>
                         return 0;<br>
diff --git a/src/shared/util.c b/src/shared/util.c<br>
index 3482b9b..6c3cf6c 100644<br>
--- a/src/shared/util.c<br>
+++ b/src/shared/util.c<br>
@@ -513,6 +513,30 @@ char *truncate_nl(char *s) {<br>
         return s;<br>
 }<br>
<br>
+char get_process_state(pid_t pid) {<br>
+        const char *p;<br>
+        int r;<br>
+<br>
+        assert(name);<br>
+        assert(pid >= 0);<br>
+<br>
+        p = procfs_file_alloca(pid, "stat");<br>
+        r = read_one_line_file(p, &line);<br>
+        if (r < 0)<br>
+                return r;<br>
+<br>
+        p = strrchr(line, ')');<br>
+        if (!p)<br>
+                return -EIO;<br>
+<br>
+        p++;<br>
+<br>
+        if (sscanf(p, " %c", &state) != 1)<br>
+                return -EIO;<br>
+<br>
+        return state;<br>
+}<br>
+<br>
 int get_process_comm(pid_t pid, char **name) {<br>
         const char *p;<br>
         int r;<br>
diff --git a/src/shared/util.h b/src/shared/util.h<br>
index 9aea3a4..8dede1f 100644<br>
--- a/src/shared/util.h<br>
+++ b/src/shared/util.h<br>
@@ -238,6 +238,7 @@ char *file_in_same_dir(const char *path, const char *filename);<br>
<br>
 int rmdir_parents(const char *path, const char *stop);<br>
<br>
+char get_process_state(pid_t pid);<br>
 int get_process_comm(pid_t pid, char **name);<br>
 int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);<br>
 int get_process_exe(pid_t pid, char **name);<br>
--<br>
1.8.5.4<br>
<br>
</blockquote></div>