aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-02-07 13:41:42 -0800
committerRob Landley <rob@landley.net>2019-02-07 19:59:59 -0600
commit638e3629916b65fa1e08d7b3e38d2d21b3594683 (patch)
treebba3272dd924af0dc5b0dc237de5f26d6c7092db /toys/posix
parentcea6a95c467dfcc1cc82ef3df0f76fccb85f5f04 (diff)
downloadtoybox-638e3629916b65fa1e08d7b3e38d2d21b3594683.tar.gz
ps, top: fix VIRT and SHR fields.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/ps.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 079bdbd6..eff980f3 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -811,10 +811,9 @@ static int get_ps(struct dirtree *new)
sprintf(buf, "%lld/statm", slot[SLOT_tid]);
if (!readfileat(fd, buf, buf, &temp)) *buf = 0;
- // Skip redundant RSS field, we got it from stat
- for (s = buf, i=0; i<3; i++)
- if (!sscanf(s, " %lld%n", slot+SLOT_vsz+i/2, &j)) slot[SLOT_vsz+i/2] = 0;
- else s += j;
+ // Skip redundant RSS field, we got it from stat.
+ slot[SLOT_vsz] = slot[SLOT_shr] = 0;
+ sscanf(buf, "%lld %*d %lld", &slot[SLOT_vsz], &slot[SLOT_shr]);
}
// Do we need to read "exe"?