aboutsummaryrefslogtreecommitdiff
path: root/procps/top.c
diff options
context:
space:
mode:
Diffstat (limited to 'procps/top.c')
-rw-r--r--procps/top.c21
1 files changed, 4 insertions, 17 deletions
diff --git a/procps/top.c b/procps/top.c
index bf30c23f6..1b6f7072f 100644
--- a/procps/top.c
+++ b/procps/top.c
@@ -29,22 +29,9 @@
29 */ 29 */
30 30
31#include "busybox.h" 31#include "busybox.h"
32#include <sys/types.h>
33#include <stdio.h>
34#include <stdlib.h>
35#include <unistd.h>
36#include <string.h>
37#include <sys/ioctl.h>
38 32
39//#define CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE /* + 2k */ 33//#define CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE /* + 2k */
40 34
41#ifdef CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE
42#include <time.h>
43#include <fcntl.h>
44#include <netinet/in.h> /* htons */
45#endif
46
47
48typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q); 35typedef int (*cmp_t)(procps_status_t *P, procps_status_t *Q);
49 36
50static procps_status_t *top; /* Hehe */ 37static procps_status_t *top; /* Hehe */
@@ -116,7 +103,7 @@ static struct jiffy_counts jif, prev_jif;
116 103
117static void get_jiffy_counts(void) 104static void get_jiffy_counts(void)
118{ 105{
119 FILE* fp = bb_xfopen("stat", "r"); 106 FILE* fp = xfopen("stat", "r");
120 prev_jif = jif; 107 prev_jif = jif;
121 if (fscanf(fp, "cpu %lld %lld %lld %lld %lld %lld %lld %lld", 108 if (fscanf(fp, "cpu %lld %lld %lld %lld %lld %lld %lld %lld",
122 &jif.usr,&jif.nic,&jif.sys,&jif.idle, 109 &jif.usr,&jif.nic,&jif.sys,&jif.idle,
@@ -196,7 +183,7 @@ static unsigned long display_generic(int scr_width)
196 unsigned int needs_conversion = 1; 183 unsigned int needs_conversion = 1;
197 184
198 /* read memory info */ 185 /* read memory info */
199 fp = bb_xfopen("meminfo", "r"); 186 fp = xfopen("meminfo", "r");
200 187
201 /* 188 /*
202 * Old kernels (such as 2.4.x) had a nice summary of memory info that 189 * Old kernels (such as 2.4.x) had a nice summary of memory info that
@@ -238,7 +225,7 @@ static unsigned long display_generic(int scr_width)
238 fclose(fp); 225 fclose(fp);
239 226
240 /* read load average as a string */ 227 /* read load average as a string */
241 fp = bb_xfopen("loadavg", "r"); 228 fp = xfopen("loadavg", "r");
242 buf[0] = '\0'; 229 buf[0] = '\0';
243 fgets(buf, sizeof(buf), fp); 230 fgets(buf, sizeof(buf), fp);
244 end = strchr(buf, ' '); 231 end = strchr(buf, ' ');
@@ -414,7 +401,7 @@ int top_main(int argc, char **argv)
414 } 401 }
415 402
416 /* change to /proc */ 403 /* change to /proc */
417 bb_xchdir("/proc"); 404 xchdir("/proc");
418#ifdef CONFIG_FEATURE_USE_TERMIOS 405#ifdef CONFIG_FEATURE_USE_TERMIOS
419 tcgetattr(0, (void *) &initial_settings); 406 tcgetattr(0, (void *) &initial_settings);
420 memcpy(&new_settings, &initial_settings, sizeof(struct termios)); 407 memcpy(&new_settings, &initial_settings, sizeof(struct termios));