+static char *get_eth_info() {
+ static char part[512];
+ char *ip_address = get_ip_address(eth_interface);
+
+ if (ip_address == NULL)
+ snprintf(part, sizeof(part), "E: down");
+ else snprintf(part, sizeof(part), "E: %s", ip_address);
+
+ return part;
+}
+
+/*
+ * Checks if the PID in path is still valid by checking if /proc/<pid> exists
+ *
+ */
+static bool process_runs(const char *path) {
+ char pidbuf[512],
+ procbuf[512],
+ *walk;
+ int n;
+ static glob_t globbuf;
+ struct stat statbuf;
+
+ if (glob(path, GLOB_NOCHECK | GLOB_TILDE, NULL, &globbuf) < 0)
+ die("glob() failed");
+ const char *real_path = (globbuf.gl_pathc > 0 ? globbuf.gl_pathv[0] : path);
+ int fd = open(real_path, O_RDONLY);
+ globfree(&globbuf);
+ if (fd < 0)
+ return false;
+ 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);
+}
+