chiark / gitweb /
service: honour that for services RestartSec=0 means immediate restarts but TimeoutSe...
[elogind.git] / src / core / killall.c
index e078012c1b9cc7d3ef9da23d30b6fea12e395075..e3950501075e736230eb3fd970faff65f17b9283 100644 (file)
@@ -32,9 +32,8 @@
 #define TIMEOUT_USEC (10 * USEC_PER_SEC)
 
 static bool ignore_proc(pid_t pid) {
-        char buf[PATH_MAX];
-        FILE *f;
-        char c;
+        _cleanup_fclose_ FILE *f = NULL;
+        char c, *p;
         size_t count;
         uid_t uid;
         int r;
@@ -51,15 +50,12 @@ static bool ignore_proc(pid_t pid) {
         if (uid != 0)
                 return false;
 
-        snprintf(buf, sizeof(buf), "/proc/%lu/cmdline", (unsigned long) pid);
-        char_array_0(buf);
-
-        f = fopen(buf, "re");
+        p = procfs_file_alloca(pid, "cmdline");
+        f = fopen(p, "re");
         if (!f)
                 return true; /* not really, but has the desired effect */
 
         count = fread(&c, 1, 1, f);
-        fclose(f);
 
         /* Kernel threads have an empty cmdline */
         if (count <= 0)