top: fix additional SEGVs if no tasks were displayable

This patch is an outgrowth of that commit shown below.

Many additional potential segmentation faults might be
encountered if interactive commands are opened up to a
user when a '-p' switch has a single non-existent pid.

[ always the 'k', 'L', 'r', 'Y' keys & maybe 'v' too ]

So, this patch will restrict such a loser (oops, user)
to a reduced subset of normal commands until he/she/it
quits then restarts top with something to be displayed
or issues the '=' command overriding that '-p' switch.

Reference(s):
commit f57a0301e3

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2020-09-13 00:00:00 -05:00 committed by Craig Small
parent f57a0301e3
commit 6e1715d9eb

View File

@ -5897,6 +5897,8 @@ static void do_key (int ch) {
write_rcfile();
goto all_done;
default: // and now, the real work...
// and just in case 'Monpids' is active but matched no processes ...
if (!Frame_maxtask && ch != '=') goto all_done;
for (i = 0; i < MAXTBL(key_tab); ++i)
if (strchr(key_tab[i].keys, ch)) {
key_tab[i].func(ch);