chiark / gitweb /
service: honour that for services RestartSec=0 means immediate restarts but TimeoutSe...
[elogind.git] / src / core / killall.c
index 7f0dbb9edf0823ccd0eb699e5dc44760bff4ac32..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)
@@ -189,7 +185,7 @@ static int killall(int sig, Set *pids) {
 
 void broadcast_signal(int sig, bool wait_for_exit) {
         sigset_t mask, oldmask;
-        Set *pids;
+        Set *pids = NULL;
 
         if (wait_for_exit)
                 pids = set_new(trivial_hash_func, trivial_compare_func);