if (e_fd) {
n = pread(e_fd, buf, sizeof(buf) - 1, 0);
- if (n > 0)
+ if (n > 0) {
+ buf[n] = '\0';
entropy_avail[sample] = atoi(buf);
+ }
}
}
close(ps->sched);
continue;
}
+ buf[s] = '\0';
if (!sscanf(buf, "%s %*s %*s", key))
continue;
if (ps->schedstat == -1)
continue;
}
-
- if (pread(ps->schedstat, buf, sizeof(buf) - 1, 0) <= 0) {
+ s = pread(ps->schedstat, buf, sizeof(buf) - 1, 0);
+ if (s <= 0) {
/* clean up our file descriptors - assume that the process exited */
close(ps->schedstat);
if (ps->sched)
// fclose(ps->smaps);
continue;
}
+ buf[s] = '\0';
+
if (!sscanf(buf, "%s %s %*s", rt, wt))
continue;
if (ps->sched == -1)
continue;
}
- if (pread(ps->sched, buf, sizeof(buf) - 1, 0) <= 0) {
+ s = pread(ps->sched, buf, sizeof(buf) - 1, 0);
+ if (s <= 0) {
/* clean up file descriptors */
close(ps->sched);
if (ps->schedstat)
// fclose(ps->smaps);
continue;
}
+ buf[s] = '\0';
if (!sscanf(buf, "%s %*s %*s", key))
continue;