From 0aa6ba5d44af32d0bf460c8d92cda686bae64c92 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 8 Feb 2007 08:21:58 +0000 Subject: make sure ps/top output what they claim: vsz, not rss ... down the line we should make the output controllable either at runtime or buildtime as both statistics are quite useful --- libbb/procps.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'libbb') diff --git a/libbb/procps.c b/libbb/procps.c index e7635e5f4..c9dcfde0c 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -127,7 +127,7 @@ procps_status_t* procps_scan(procps_status_t* sp, int flags) * ("continue" would mean that current /proc/NNN * is not a valid process info) */ - memset(&sp->rss, 0, sizeof(*sp) - offsetof(procps_status_t, rss)); + memset(&sp->vsz, 0, sizeof(*sp) - offsetof(procps_status_t, vsz)); sp->pid = pid; if (!(flags & ~PSSCAN_PID)) break; @@ -164,17 +164,16 @@ procps_status_t* procps_scan(procps_status_t* sp, int flags) "%*s %*s %*s " /* cutime, cstime, priority */ "%ld " /* nice */ "%*s %*s %*s " /* timeout, it_real_value, start_time */ - "%*s " /* vsize */ - "%lu", /* rss */ + "%lu ", /* vsize */ sp->state, &sp->ppid, &sp->pgid, &sp->sid, &sp->utime, &sp->stime, &tasknice, - &sp->rss); + &sp->vsz); if (n != 8) break; - if (sp->rss == 0 && sp->state[0] != 'Z') + if (sp->vsz == 0 && sp->state[0] != 'Z') sp->state[1] = 'W'; else sp->state[1] = ' '; @@ -185,11 +184,7 @@ procps_status_t* procps_scan(procps_status_t* sp, int flags) else sp->state[2] = ' '; -#ifdef PAGE_SHIFT - sp->rss <<= (PAGE_SHIFT - 10); /* 2**10 = 1kb */ -#else - sp->rss *= (getpagesize() >> 10); /* 2**10 = 1kb */ -#endif + sp->vsz >>= 10; /* vsize is in bytes and we want kb */ } if (flags & PSSCAN_CMD) { @@ -230,7 +225,6 @@ procps_status_t* procps_scan(procps_status_t* sp, int flags) tty_pgrp, task->flags, min_flt, - cmin_flt, maj_flt, cmaj_flt, -- cgit v1.2.3