#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;
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)
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);