diff options
Diffstat (limited to 'toys/posix/ps.c')
-rw-r--r-- | toys/posix/ps.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c index 26b4a4ea..a1e1981a 100644 --- a/toys/posix/ps.c +++ b/toys/posix/ps.c @@ -1144,6 +1144,8 @@ static int header_line(int line, int rev) { if (!line) return 0; + if (toys.optflags&FLAG_b) rev = 0; + printf("%s%*.*s%s\r\n", rev ? "\033[7m" : "", (toys.optflags&FLAG_b) ? 0 : -TT.width, TT.width, toybuf, rev ? "\033[0m" : ""); @@ -1339,7 +1341,8 @@ static void top_common( *pos = 0; lines = header_line(lines, 1); } - if (!recalc) printf("\033[%dH\033[J", 1+TT.height-lines); + if (!recalc && !(toys.optflags&FLAG_b)) + printf("\033[%dH\033[J", 1+TT.height-lines); recalc = 1; for (i = 0; i<lines && i+topoff<mix.count; i++) { @@ -1357,6 +1360,14 @@ static void top_common( if (timeout<=now) timeout = new.whence+TT.top.d; if (timeout<=now || timeout>now+TT.top.d) timeout = now+TT.top.d; + // In batch mode, we ignore the keyboard. + if (toys.optflags&FLAG_b) { + msleep(timeout-now); + // Make an obvious gap between datasets. + xputs("\n\n\n"); + continue; + } + i = scan_key_getsize(scratch, timeout-now, &TT.width, &TT.height); if (i==-1 || i==3 || toupper(i)=='Q') { done++; |