9fc0f6
From 54461c902d71e43fd5cc0010e0352903685c3974 Mon Sep 17 00:00:00 2001
9fc0f6
From: Yuxuan Shui <yshuiv7@gmail.com>
9fc0f6
Date: Sat, 15 Feb 2014 13:20:55 +0800
9fc0f6
Subject: [PATCH] core: check for return value from get_process_state
9fc0f6
9fc0f6
Fix for commit e10c9985bb.
9fc0f6
---
9fc0f6
 src/core/service.c | 12 +++++++++---
9fc0f6
 1 file changed, 9 insertions(+), 3 deletions(-)
9fc0f6
9fc0f6
diff --git a/src/core/service.c b/src/core/service.c
9fc0f6
index 3eacf3b..f6fdbbc 100644
9fc0f6
--- a/src/core/service.c
9fc0f6
+++ b/src/core/service.c
9fc0f6
@@ -1429,11 +1429,17 @@ static int service_load_pid_file(Service *s, bool may_warn) {
9fc0f6
                 return -ESRCH;
9fc0f6
         }
9fc0f6
 
9fc0f6
-        if (get_process_state(pid) == 'Z') {
9fc0f6
+        r = get_process_state(pid);
9fc0f6
+        if (r < 0) {
9fc0f6
+                if (may_warn)
9fc0f6
+                        log_info_unit(UNIT(s)->id, "Failed to read /proc/%d/stat: %s",
9fc0f6
+                                      pid, strerror(-r));
9fc0f6
+                return r;
9fc0f6
+        } else if (r == 'Z') {
9fc0f6
                 if (may_warn)
9fc0f6
                         log_info_unit(UNIT(s)->id,
9fc0f6
-                                      "PID "PID_FMT" read from file %s is a zombie.",
9fc0f6
-                                      pid, s->pid_file);
9fc0f6
+                                      "PID %lu read from file %s is a zombie.",
9fc0f6
+                                      (unsigned long) pid, s->pid_file);
9fc0f6
                 return -ESRCH;
9fc0f6
         }
9fc0f6