diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-10 17:11:59 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-10 17:11:59 +0000 |
commit | 5a65447e3090908b4bad645c84e37298ca7a7449 (patch) | |
tree | 1fb67f517a8519f92e5d5c9876685823dff5b236 /libbb | |
parent | e8a0788b249cbac5bf5b2aa2d81bb8f6b29a7a4b (diff) | |
download | busybox-w32-5a65447e3090908b4bad645c84e37298ca7a7449.tar.gz busybox-w32-5a65447e3090908b4bad645c84e37298ca7a7449.tar.bz2 busybox-w32-5a65447e3090908b4bad645c84e37298ca7a7449.zip |
top: add config option and code for global CPU % display
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/procps.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libbb/procps.c b/libbb/procps.c index be0d61bd3..1e2495a5a 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -79,8 +79,15 @@ const char* get_cached_groupname(gid_t gid) | |||
79 | 79 | ||
80 | static int read_to_buf(const char *filename, void *buf) | 80 | static int read_to_buf(const char *filename, void *buf) |
81 | { | 81 | { |
82 | ssize_t ret; | 82 | int fd; |
83 | ret = open_read_close(filename, buf, PROCPS_BUFSIZE-1); | 83 | /* open_read_close() would do two reads, checking for EOF. |
84 | * When you have 10000 /proc/$NUM/stat to read, it isn't desirable */ | ||
85 | ssize_t ret = -1; | ||
86 | fd = open(filename, O_RDONLY); | ||
87 | if (fd >= 0) { | ||
88 | ret = read(fd, buf, PROCPS_BUFSIZE-1); | ||
89 | close(fd); | ||
90 | } | ||
84 | ((char *)buf)[ret > 0 ? ret : 0] = '\0'; | 91 | ((char *)buf)[ret > 0 ? ret : 0] = '\0'; |
85 | return ret; | 92 | return ret; |
86 | } | 93 | } |