]> git.sur5r.net Git - i3/i3status/commitdiff
Strip all non-digit characters from pidbuf
authorMichael Stapelberg <michael+x200@stapelberg.de>
Tue, 7 Oct 2008 09:22:35 +0000 (11:22 +0200)
committerMichael Stapelberg <michael+x200@stapelberg.de>
Tue, 7 Oct 2008 09:22:35 +0000 (11:22 +0200)
This is needed for dhclient's pidfile, as it contains a newline

config.h
wmiistatus.c

index c142add99267b932db0d0a662c8d00d811b08ede..baaa24040f66196c3d8ec1d016099555bf0b337c 100644 (file)
--- a/config.h
+++ b/config.h
@@ -3,5 +3,5 @@ const char *eth_interface = "eth0";
 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"};
index 00aa487aab8390490a956d06dd36c54caef64443..bdb1e6a5ed8bbcc795b1815cec8f5c9ac2017711 100644 (file)
@@ -246,7 +246,9 @@ static char *get_eth_info() {
  */
 static bool process_runs(const char *path) {
        char pidbuf[512],
-            procbuf[512];
+            procbuf[512],
+            *walk;
+       int n;
        static glob_t globbuf;
        struct stat statbuf;
 
@@ -257,8 +259,15 @@ static bool process_runs(const char *path) {
        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);
 }