14 * Checks if the PID in path is still valid by sending signal 0 (does not do
15 * anything). kill() will return ESRCH if the process does not exist and 0 or
16 * EPERM (depending on the uid) if it exists.
19 bool process_runs(const char *path) {
20 static char pidbuf[16];
21 static glob_t globbuf;
22 memset(pidbuf, 0, sizeof(pidbuf));
24 if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
25 die("glob() failed\n");
26 if (!slurp((globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path), pidbuf, sizeof(pidbuf))) {
32 return (kill(strtol(pidbuf, NULL, 10), 0) == 0 || errno == EPERM);