diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-27 17:04:47 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-27 17:04:47 +0200 |
commit | 9f752ce1f6ec7b7544b15a6e48682da5065c297b (patch) | |
tree | a920d04c7b95e5f1990901e2a69762c19f6d0f71 /Userland/top.cpp | |
parent | b6e29656a16b2eacf446d156abc6d6126edb237a (diff) | |
download | serenity-9f752ce1f6ec7b7544b15a6e48682da5065c297b.zip |
top: Don't print more lines than the terminal can fit
Diffstat (limited to 'Userland/top.cpp')
-rw-r--r-- | Userland/top.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/top.cpp b/Userland/top.cpp index 56d6db8e15..46c82d0479 100644 --- a/Userland/top.cpp +++ b/Userland/top.cpp @@ -211,6 +211,7 @@ int main(int, char**) return p2->times_scheduled_since_prev < p1->times_scheduled_since_prev; }); + int row = 0; for (auto* thread : threads) { int nprinted = printf("%6d %3d %2u %-9s %-10s %6zu %6zu %2u.%1u ", thread->pid, @@ -226,6 +227,9 @@ int main(int, char**) int remaining = g_window_size.ws_col - nprinted; fwrite(thread->name.characters(), 1, max(0, min(remaining, (int)thread->name.length())), stdout); putchar('\n'); + + if (++row >= (g_window_size.ws_row - 2)) + break; } threads.clear_with_capacity(); prev = move(current); |