aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
Diffstat (limited to 'toys')
-rw-r--r--toys/posix/ps.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 3a39353a..6b89c5ff 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -1228,13 +1228,11 @@ static int header_line(int line, int rev)
return line-1;
}
-// Get current time in miliseconds
-static long long militime(void)
+static long long millitime(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
-
return ts.tv_sec*1000+ts.tv_nsec/1000000;
}
@@ -1264,7 +1262,7 @@ static void top_common(
plold = plist+(tock++&1);
plnew = plist+(tock&1);
- plnew->whence = militime();
+ plnew->whence = millitime();
dt = dirtree_read("/proc", get_ps);
plnew->tb = collate(plnew->count = TT.kcount, dt);
TT.kcount = 0;
@@ -1421,7 +1419,7 @@ static void top_common(
recalc = 1;
for (i = 0; i<lines && i+topoff<mix.count; i++) {
- if (i) xputc('\n');
+ if (!(toys.optflags&FLAG_b) && i) xputc('\n');
show_ps(mix.tb[i+topoff]);
}
@@ -1430,8 +1428,7 @@ static void top_common(
break;
}
- // Get current time in miliseconds
- now = militime();
+ now = millitime();
if (timeout<=now) timeout = new.whence+TT.top.d;
if (timeout<=now || timeout>now+TT.top.d) timeout = now+TT.top.d;
@@ -1439,7 +1436,7 @@ static void top_common(
if (toys.optflags&FLAG_b) {
msleep(timeout-now);
// Make an obvious gap between datasets.
- xputs("\n\n\n");
+ xputs("\n\n");
continue;
}
@@ -1488,10 +1485,10 @@ static void top_setup(char *defo, char *defk)
{
int len;
- TT.time = militime();
TT.top.d *= 1000;
if (toys.optflags&FLAG_b) TT.width = TT.height = 99999;
else {
+ TT.time = millitime();
set_terminal(0, 1, 0);
sigatexit(tty_sigreset);
xsignal(SIGWINCH, generic_signal);
@@ -1532,7 +1529,7 @@ void top_main(void)
static int iotop_filter(long long *oslot, long long *nslot, int milis)
{
if (!(toys.optflags&FLAG_a)) merge_deltas(oslot, nslot, milis);
- else oslot[SLOT_upticks] = ((militime()-TT.time)*TT.ticks)/1000;
+ else oslot[SLOT_upticks] = ((millitime()-TT.time)*TT.ticks)/1000;
return !(toys.optflags&FLAG_o)||oslot[SLOT_iobytes+!(toys.optflags&FLAG_A)];
}