chiark / gitweb /
core: check for return value from get_process_state
authorYuxuan Shui <yshuiv7@gmail.com>
Sat, 15 Feb 2014 05:20:55 +0000 (13:20 +0800)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sun, 16 Feb 2014 16:09:51 +0000 (11:09 -0500)
Fix for commit e10c9985bb.

src/core/service.c

index 3a2ef015708311fd6bb3a0a838428c8504eb5407..8e07bd0170c187513812185b1e21dac8fa7f41ba 100644 (file)
@@ -1376,7 +1376,13 @@ static int service_load_pid_file(Service *s, bool may_warn) {
                 return -ESRCH;
         }
 
                 return -ESRCH;
         }
 
-        if (get_process_state(pid) == 'Z') {
+        r = get_process_state(pid);
+        if (r < 0) {
+                if (may_warn)
+                        log_info_unit(UNIT(s)->id, "Failed to read /proc/%d/stat: %s",
+                                      pid, strerror(-r));
+                return r;
+        } else if (r == 'Z') {
                 if (may_warn)
                         log_info_unit(UNIT(s)->id,
                                       "PID "PID_FMT" read from file %s is a zombie.",
                 if (may_warn)
                         log_info_unit(UNIT(s)->id,
                                       "PID "PID_FMT" read from file %s is a zombie.",