[systemd-devel] [PATCH] core: small fixes for commit e10c9985bb.

Yuxuan Shui yshuiv7 at gmail.com
Fri Feb 14 21:20:55 PST 2014


Fix function prototype and check for return value.
---
 src/core/service.c | 10 +++++++++-
 src/shared/util.h  |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/core/service.c b/src/core/service.c
index 3a2ef01..efccdbf 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1376,7 +1376,15 @@ static int service_load_pid_file(Service *s, bool may_warn) {
                 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",
+                                      pid);
+                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.",
diff --git a/src/shared/util.h b/src/shared/util.h
index 8dede1f..fcb45b5 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -238,7 +238,7 @@ char *file_in_same_dir(const char *path, const char *filename);
 
 int rmdir_parents(const char *path, const char *stop);
 
-char get_process_state(pid_t pid);
+int get_process_state(pid_t pid);
 int get_process_comm(pid_t pid, char **name);
 int get_process_cmdline(pid_t pid, size_t max_length, bool comm_fallback, char **line);
 int get_process_exe(pid_t pid, char **name);
-- 
1.8.5.5



More information about the systemd-devel mailing list