chiark / gitweb /
Add some extra __attribute__ ((format)) s
[elogind.git] / src / core / killall.c
index 7f0dbb9edf0823ccd0eb699e5dc44760bff4ac32..a0f57455fb41ffb25062f1d8b33e533f3974215f 100644 (file)
@@ -32,8 +32,7 @@
 #define TIMEOUT_USEC (10 * USEC_PER_SEC)
 
 static bool ignore_proc(pid_t pid) {
-        char buf[PATH_MAX];
-        FILE *f;
+        _cleanup_fclose_ FILE *f = NULL;
         char c;
         size_t count;
         uid_t uid;
@@ -51,15 +50,11 @@ 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");
+        f = fopen(procfs_file_alloca(pid, "cmdline"), "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 +184,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);