This is needed for dhclient's pidfile, as it contains a newline
const char *wmii_path = "/mnt/wmii/rbar/status";
const char *time_format = "%d.%m.%Y %H:%M:%S";
const char *battery = "/sys/class/power_supply/BAT0/uevent";
-const char *run_watches[] = {"DHCP", "/var/run/dhclient*.pid",
+const char *run_watches[] = {"DHCP", "/var/run/dhclient.pid",
"VPN", "/var/run/vpnc*.pid"};
*/
static bool process_runs(const char *path) {
char pidbuf[512],
- procbuf[512];
+ procbuf[512],
+ *walk;
+ int n;
static glob_t globbuf;
struct stat statbuf;
globfree(&globbuf);
if (fd < 0)
return false;
- read(fd, pidbuf, sizeof(pidbuf));
+ n = read(fd, pidbuf, sizeof(pidbuf));
+ if (n > 0)
+ pidbuf[n] = '\0';
close(fd);
+ for (walk = pidbuf; *walk != '\0'; walk++)
+ if (!isdigit((int)(*walk))) {
+ *walk = '\0';
+ break;
+ }
sprintf(procbuf, "/proc/%s", pidbuf);
return (stat(procbuf, &statbuf) >= 0);
}