From 31885cd5e38ec9807a6a7ab32660cf8c2fcf48f7 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Wed, 17 Apr 2013 17:19:38 -0400 Subject: core/killall: use procfs_file_alloca --- src/shared/util.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/shared/util.h') diff --git a/src/shared/util.h b/src/shared/util.h index cfb54939cd..6575f56811 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -21,6 +21,7 @@ along with systemd; If not, see . ***/ +#include #include #include #include @@ -696,3 +697,12 @@ int unlink_noerrno(const char *path); strcpy(stpcpy(_c_, _a_), _b_); \ _c_; \ }) + +#define procfs_file_alloca(pid, field) \ + ({ \ + pid_t _pid_ = (pid); \ + char *_r_; \ + _r_ = alloca(sizeof("/proc/") -1 + DECIMAL_STR_MAX(pid_t) + 1 + sizeof(field)); \ + sprintf(_r_, "/proc/%lu/" field, (unsigned long) _pid_); \ + _r_; \ + }) -- cgit v1.2.3-54-g00ecf