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