summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-17 17:19:38 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-19 10:10:41 -0400
commit31885cd5e38ec9807a6a7ab32660cf8c2fcf48f7 (patch)
tree2f16e9f5adb26c4ef2f50f85cda9042de8243efc /src/core
parentbdd29249a882e599e5e365536372d08dee398cd4 (diff)
core/killall: use procfs_file_alloca
Diffstat (limited to 'src/core')
-rw-r--r--src/core/killall.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/core/killall.c b/src/core/killall.c
index e078012c1b..a0f57455fb 100644
--- a/src/core/killall.c
+++ b/src/core/killall.c
@@ -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)