Commit Graph

518 Commits

Author SHA1 Message Date
Jim Warner
371e9138ba top: bring the namespaces up to date with linux kernel
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-09 18:44:21 +10:00
Jim Warner
3f068a66c8 top: turn off the 'Ctrl' bottom window with 1 more key
In that commit shown below, the concept of a corrupted
display was introduced so that 'Ctrl' windows could be
redrawn now that they were made more persistent. Well,
it turns out there is another case where redrawing was
necessary. That is when transitioning between task and
thread modes. So this patch addresses those occasions.

Reference(s):
. May, 2022 - introduced Frames_signal BREAK_screen
commit d66c1f39b5

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-09 18:44:21 +10:00
Jim Warner
793f3e85ae top: fix a bug from when 'Ctrl' window was made sticky
In the patch referenced below the bottom 'Ctrl' window
was made to remain until it was dismissed by the user.

As such, it required abandoning a 'Cap_nl_clreos' used
when all the terminal rows had not been drawn. Instead
each line had to be cleared individually until the row
reserved for that 'Ctrl' window area had been reached.

Unfortunately, while a 'Cap_nl_clreos' didn't create a
problem for 'batch' mode, a 'Cap_clr_eol' used instead
yielded an unending loop if those rows were limitless.

So, now we will only clear that area when top isn't in
'batch' mode (which should have always been the case).

Reference(s):
. May, 2022 - bottom window made sticky
commit 0f2a755b0b

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-09 18:44:20 +10:00
Jim Warner
bc4b499ed2 top: avoid library shame with refactored 'Ctrl' window
Well darn it, whoever wrote that new library caught me
with my pants down (again?). Shoot, they were not just
down but somehow missing altogether. Here's the story.

Any item from that library supported by dynamic memory
can only be represented in user's stacks exactly once.

Should any string based enumerator be duplicated among
the items array, for any instance beyond the first the
library will return '[ duplicate ENUM ]' for a result.

That's where I lost my pants. While command lines were
given special handling (and never duplicated) I failed
to turn on CGROUPS, SUPGRPS & ENVIRON when testing the
Ctrl-G, Ctrl-U & Ctrl-N keys. If any of those 3 are on
that's when a Ctrl window sees a 'duplicate' notation.

[ and who runs top with such fields displayed anyway ]

In responding to this oops, the internals were changed
quite dramatically & vastly simplified in the process.

More importantly, the 'duplicate' results are no more.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-04 16:45:57 +10:00
Jim Warner
d66c1f39b5 top: turn off the 'Ctrl' bottom window after some keys
To complete the implementation of this new feature, we
must address the problem created by any commands which
offer their own full replacement displays. Should that
'Ctrl' bottom window be active, a return from any such
command leaves that lower portion of a terminal blank.

While we could issue a 'TAGGED_TOSS' macro right after
invoking any of those 4 (currently) affected commands,
it is wrong to make them aware of this 'tagged' stuff.

So, I'll opt for a more generalized solution whereby a
notice regarding a corrupted screen is broadcast. Then
the logic already aware of 'tagging' can deal with it.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Jim Warner
16e202d26d top: allow sticky 'Ctrl' bottom window code by #define
After making that new bottom window more persistent, I
decided to offer a build choice for somebody who might
prefer to have the rug pulled out from under him while
reviewing window contents should some target task end.

If 'TAGGED_BRIEF' is defined old behavior is restored.

[ it should be noted, however, that when this define ]
[ is active we'll lose any benefit of onetime update ]
[ for the bottom window. just like with the original ]
[ behavior, it is repainted with every update cycle. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Jim Warner
9ff5a4fff0 top: trade just 1 'Ctrl' bottom window key association
I grew tired of inadvertently causing a premature exit
from top when all I wanted was to review some process'
environment variables. That 'V' key was just too close
to the 'C' key so the '^V' attempt became one of '^C'.

Well, not any more. Should a user wish to see a task's
environment, it will now require the '^N' combination.

[ it also now places G/U & N/K on a similar diagonal ]

Along the way, lower case Ctrl key combinations on the
help screen were all changed into upper case versions.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Jim Warner
0f2a755b0b top: make the new 'Ctrl' bottom window behavior sticky
After using this new feature for awhile, I encountered
numerous times when that 'Ctrl' window would disappear
as I was studying the contents. This was caused by the
death of the target task but it made me think that the
window could/should persist until dismissed by a user.

Well, now it will persist until that same Ctrl key has
been struck a 2nd time or a different Ctrl key used to
target another process after positioning it on row #1.

So now, instead of that former 'moving target' type of
approach, this window is more of a 'snapshot' in time.

[ even more significant, perhaps, is the fact that a ]
[ Ctrl window will now be drawn exactly 1 time only, ]
[ instead of being repainted after each delay cycle. ]

[ this will remain true no matter how many intervals ]
[ might elapse while its contents were under review. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Jim Warner
bad7f2a263 top: add a program name to 'Ctrl' bottom window header
This minor addition to that new 'Ctrl' feature is more
important than it seems. It's responsible for alerting
yours truly to the 'LIBPROC_HIDE_KERNEL' bug addressed
in the very next commit. All this while, program names
for some tasks would be mysteriously replaced with the
kernel 'kworker' names. However, customary clutter for
the top process display tended to obscure such a fact.

[ and, of course, to notice the problem in the first ]
[ place required one to have the command line toggle ]
[ 'off' or perhaps to toggle its state 'on' & 'off'. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Jim Warner
fb32021eeb top: add variable width data display without scrolling
There are times when one might want to see some task's
particular variable width data. However, prior to this
commit, the only way was to first turn on a field then
scroll through it via repeated right arrow keystrokes.

[ this also required that field to be displayed last ]

Needless to say, given the potential length of some of
that variable data this could be extremely cumbersome.

Now with this patch, a Ctrl keystroke combination will
create a separate window at the bottom of the terminal
screen where such variable width data is seen in full.

[ the targeted task is the 1st task displayed, which ]
[ is a convention employed in some existing commands ]

[ the targeted data was determined by these Ctrl key ]
[ combinations: CtrlG = ctrl group; CtrlK = cmdline; ]
[ CtrlU = supplementary groups; plus CtrlV = environ ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Jim Warner
27f5904edd top: eliminate the 'keys_global' redundant definitions
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-03 19:21:21 +10:00
Jim Warner
e18981ec0a top: added provision for autogroup nice (AGNI) changes
When autogroups are active programs such as renice and
nice are basically useless because the nice value will
only affect the target task priority relative to other
processes in the same autogroup. So to accomplish what
we thought of as renice, /proc/<pid>/autogroup must be
changed. Altering a single member in an autogroup will
also affect every other member of that same autogroup.

Since top's renice provision ('r') suffers constraints
like those of the stand alone nice/renice programs, we
will now provide a means to manipulate that nice value
found within some process' /proc/<pid>/autogroup file.

[ to alter this file for other user's tasks requires ]
[ root privileges, as does setting a negative value. ]

[ however, unlike that 'r' command, this new command ]
[ allows raising *and* lowering all positive values. ]

Reference(s):
. Aug 2021, autogroups added to librady
commit 631e5d91f3
. Aug 2021, autogroups added to top
commit b789b46f84

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-26 20:18:15 +10:00
Jim Warner
71d7cc512a top: the '%CUC' column must be just a little bit wider
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-22 12:02:30 +10:00
Jim Warner
ef8d1cb6e3 top: remove those winflags which restricted 'x' toggle
On occasion, even as the top author, I wonder why that
'x' toggle has stopped working. Of course, it actually
was working but a locate request ('L') or other filter
('O') operation was active and thus temporarily turned
if off. Such behavior is documented in top's man page.

Well, with this patch that 'x' suppression is no more.

[ the original justification, however, remains true. ]

[ but there's really only one character which causes ]
[ any potential trouble & i'm gonna' keep it secret. ]

[ besides, if a display is corrupted, there's always ]
[ that '=' key which restores things back to normal. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-17 10:43:19 +10:00
Jim Warner
7279cd8e4d top: raise %CPU maximum if large numbers of processors
It would appear that openSUSE was the first to release
procps-ng version 4.0.0 (in the tumbleweed distro). As
a result I checked their source rpm and found a couple
of patches I'm porting to newlib for the next release.

This particulate patch, with some changes, is openSUSE
patch 'procps-ng-3.3.10-large_pcpu.patch'. The changes
were strictly cosmetic. They involved whitespace only.

[ it should be noted that the net effect for raising ]
[ the maximum is to produce a '?' in the %CPU field. ]
[ that's because its width is fixed at five columns. ]
[ but at least the '?' won't distort actual results. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-11 16:41:12 +10:00
Jim Warner
6aec3ec93a top: ignore the SIGHUP signal if running in batch mode
It would appear that openSUSE was the first to release
procps-ng version 4.0.0 (in the tumbleweed distro). As
a result I checked their source rpm and found a couple
of patches I'm porting to newlib for the next release.

This particulate commit was a refactor of the openSUSE
patch 'procps-ng-3.3.8-bnc634840.patch'. Unfortunately
their original patch did not have the intended effect.

That was because the amended signal handling logic was
performed well before the command line parameters were
parsed. So the global 'Batch' flag was in its 0 state.

. what follows is the original openSUSE commit message
------------------------------------------------------
Do not setup SIGHUP signal handler if we are in the batch mode

Top enables a signal handler for the SIGHUP signal (loss of terminal).  While
this makes sense for top's default interactive mode, it doesn't make any sense
for batch mode. If you run top in nohup just to collect data over time and
disconnect top finishes which is not what one would expect.
------------------------------------------------------

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-11 16:41:12 +10:00
Jim Warner
28c50b8564 top: update one function prologue after rcfile changes
When top's rcfile was reorganized, trading that 'char'
based field representation for the 'int' scheme, there
was a function prologue that should have been changed.

Thus, this patch will correct that original oversight.

Reference(s):
. Mar, 2022 - rcfile reorganized
commit 46aa96e438

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-04-01 17:13:25 +11:00
Jim Warner
8502c49619 top: why not maximize usage of some manifest constants
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-22 19:49:03 +11:00
Jim Warner
8a5f3f7b26 top: fix initial cursor position for fields management
When we transitioned from 'char' based fields to 'int'
proper initial cursor positioning (highlight) was lost
in the 'fields_utility' function. The highlight should
appear on the current sort field. Instead, however, it
was often positioned on the first field listed or some
completely different field other than that sort field.

So this patch will restore the master branch behavior.

[ and on the assumption that a sort field is visible ]
[ we will search first for a field with the 'on' bit ]

Reference(s):
. Mar, 2022 - trade 'char' for 'int'
commit 46aa96e438

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-21 21:13:46 +11:00
Jim Warner
6c35695485 top: add more robustness to logic for reading a rcfile
At this point I don't know if the Rc.id ever carried a
value of 'b', 'c', 'd' or 'e' in a public release. But
I do know that those values ought not to be recognized
in any configuration file. Now they won't be for sure.

[ the net result is that now a user with such a file ]
[ will see the 'incompatible rcfile' message instead ]
[ of that misleading 'window entry corrupt' message. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-21 21:13:07 +11:00
Jim Warner
255383a8cd top: do not add an extra line when rewritting a rcfile
When the configuration file is first written, there is
just the normal single newline which ends that rcfile.

However, when any existing rcfile was rewritten, there
was one extra newline '\n' character added at the end.
This will happen just once. The file does NOT continue
to grow with the extra blank lines always being added.

Anyway, this patch will put an end to such a practice.

[ along the way i fixed an unrelated whitespace oops ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-21 21:13:07 +11:00
Jim Warner
5822210618 top: swat a bug with 3.2.8 support for field additions
This new integer based version of 'fieldscur' deviated
a bit too much from that character based logic when it
comes to ancient 3.2.8 rcfile support. This results in
an inappropriate extra field shown as the last column.

If we're truly dealing with 20 year old 3.2.8 rcfiles,
it's important the 3.3.9 extension (RCF_PLUS_H) not be
concatenated to what was read. That's because a search
for the special SUSE characters will always find a '\'
in the 26th position (after normal 3.2.8 'fieldscur').

[ for symmetry, we'll also avoid RCF_PLUS_J (3.3.17) ]

All other 'old' rcfiles are transformed without error.

Reference(s):
. Mar, 2022 - 3.2.8 support restores

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-15 22:02:46 +11:00
Jim Warner
980dc08a5b top: honor old rcfiles after change to field additions
This patch will restore the previously abandoned older
rcfile support. To be honest, I wasn't sure this would
be possible given the vast difference between formats.

But after some very intense hacking our newlib top can
again fully support seamless migration from some older
'char' based file to this new 'int' based file format.

[ top even supports a 20+ year old 3.2.8 config file ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-15 22:01:32 +11:00
Jim Warner
46aa96e438 top: provide an unlimited capacity for field additions
With each of those references shown below, the maximum
number of fields was increased. However, with a 'char'
based implementation we're nearing the upper limits of
total displayable fields. We currently use 76 of a max
of 86 fields. With extra effort, 94 might be possible.

But 94 is the absolute upper limit of possible fields!

Moreover, the current implementation yields characters
that were unprintable in the rcfile. This could become
an issue with that 'inspect' feature when/if an rcfile
is edited to add entries (as opposed to using 'echo').

So, with this commit the internals of field management
has been completely reimagined. It is now based on the
integer type, not a character. And whereas that former
design used the high order bit to show the 'on' state,
thus yielding an unprintable character, the new design
uses the low order bit for the state. As such, numbers
will be kept small and an even number will be an 'off'
field whereas an odd number will become an 'on' state.

The bottom line is that this new design will afford an
unlimited number of new fields while keeping an rcfile
completely free of that potential unprintable garbage.

And it is embarrassingly easy to extend the maximum of
supportable fields from the currently implemented 100.
Who knows, maybe a future patch will prove this point.

[ unless a subsequent commit proves otherwise, given ]
[ the dramatic differences in rcfile contents, i had ]
[ to abandon the practice of supporting old rcfiles. ]

Reference(s):
. Nov, 2013 - RCF_PLUS_H introduced
commit af4e6533ba
. Jul, 2016 - RCF_PLUS_J introduced
commit d5c5051fb3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-15 22:01:32 +11:00
Jim Warner
cfa5538832 top: and for symmetry 'UTILIZATION_C' is newest column
This commit just compliments a change referenced below
by providing the value which includes reaped children.

Reference(s):
. Feb, 2022 - added %CUU field
commit 7647e96b0a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-07 20:29:06 +11:00
Jim Warner
e4e7991a26 top: enhanced 'scale_tics' function for Ctrl-E scaling
When scale_tics was refactored and then Ctrl-E support
added to top, the complete range of scaling values was
not visible. Namely, a single 'd' (days) & 'w' (weeks)
was never seen with ^E. With this commit they will be.

Reference(s):
. Mar, 2022 - introduced ^E tics scaling
commit 402bf1903b
. Mar, 2022 - refactored scale_tics
commit 71eb90c1b2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-07 20:29:06 +11:00
Jim Warner
402bf1903b top: extended 'scale_tics' function for Ctrl-E scaling
That normalization of the 'scale_tics' function in the
prior commit convinced me that I won't please everyone
with my arbitrary choices for the scaling transitions.

So, this patch will provide the users with a means for
setting their own scaling transition points with a new
toggle. Ctrl-E was chosen since the 'e/E' toggles were
already present as a means of scaling (albeit memory).

[ this toggle will also serve an educational purpose ]
[ by allowing one to see all the scaling conventions ]

The scaling a user establishes is saved in the rcfile.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-06 14:52:34 +11:00
Jim Warner
71eb90c1b2 top: refactor 'scale_tics' function for better scaling
This patch refactors the 'scale_tics' function to more
closely parallel uptime shown on the first line of the
summary area. The old logic has been preserved through
the header file's new  #define SCALE_FORMER provision.

However, the former logic was actually a big disaster.
These are some potential problems with that old logic:

1. With respect to our time fields top no longer deals
solely with cpu time. So, the old limits of '68 weeks'
could possibly be insufficient to reflect those times.

2. Given the widths of top's new time fields, the code
never got beyond scaling to hours. For example, with a
ridiculously large span of 19 years, the scaled result
would then be shown as '167832h'. We never reached the
days ('6993d') or even the weeks ('999w') equivalents.

3. Similarly, with that 'TIME+' field and a large tics
value, results would then appear as 'MMMMMM:SS' rather
than the more meaningful 'HH:MM:SS' or days and hours.

So henceforth we will adopt these scaling conventions:

  MMM:SS.hh ... minutes:seconds.hundredths
  MMM:SS ...... minutes:seconds
  HH,MM ....... hours,minutes
  D+H ......... days+hours (with 'd' & 'h' suffixes)
  D ........... days (with 'd' suffix)
  W+D ......... weeks+days (with 'w' & 'd' suffixes)
  W ........... weeks (with 'w' suffix)

Note that, unlike our former scaling logic, that 'MMM'
portion won't be allowed to grow unconditionally. It's
limited (arbitrarily?) to 360 total minutes (6 hours).
Additionally, the 'HH' guy will be limited to 96 hours
(4 days) while that 'D' limit was set at 14 (2 weeks).

Whenever a limit is hit, scaling will advance a level.

Reference(s):
. Feb, 2022 - added 'ELAPSED'
commit 9348d3b008
. Feb, 2022 - added 'STARTED'
commit 7647e96b0a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-03-06 14:52:34 +11:00
Jim Warner
9348d3b008 top: added some elapsed running time 'ELAPSED' support
When the 'STARTED' field was added, in the message for
the commit referenced below, I explained why 'ELAPSED'
shouldn't be implemented though it might be preferred.

Well, after climbing out of my box to do a little more
thinking, I came up with the way to add that 'ELAPSED'
field while avoiding the possible performance penalty.

Just do not show what would change with every refresh!

If we do not show the seconds portion of a scaled tics
amount then the problem goes away. And this comes with
an additional benefit. The HH,MM (hours,minutes) style
then is readily compared with that system uptime shown
as HH:MM. The only difference is just the comma/colon.

[ assuming the top uptime/load average toggle was on ]

Reference(s):
. introduced 'start time' field
commit 7647e96b0a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-28 20:21:00 +11:00
Jim Warner
a749414f16 top: tweaked the recently introduced 'STARTED' support
When the 'STARTED' field was added, the width was made
the same as the 'TIME+' field. Thus, a full time could
be shown (which then included hundredths of a second).

That kind of granularity is totally unnecessary. After
all, this column is potentially confusing enough since
it is so counterintuitive. So, this commit will reduce
the width of the field with some help from scale_tics.

Henceforth it will not include those ol' centiseconds.

[ along the way let's expand the man document with a ]
[ a remainder about content representation & scaling ]

Reference(s):
. introduced 'start time' field
commit 7647e96b0a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-28 20:21:00 +11:00
Jim Warner
7647e96b0a top: added fields for 'start time' & 'cpu utilization'
This patch will exploit some new library capabilities.

[ one will raise eyebrows, the other likely will not ]

A new 'STARTED' field was added which shows the time a
process started after system boot. As such the largest
interval represents the most recently started process.

This is the field that will likely be questioned since
it's somewhat counterintuitive. But were we to instead
use TIME_ELAPSED, the value will change with every top
refresh. This will defeat any PUFF macro optimization.

The new '%CUU' field will probably be better received.
It represents the cpu usage over the life of the task.
When a process was showing high %CPU usage, this field
can be used to determine if it's an anomaly or normal.

[ and as with %CPU, %CUU shows a '?' when running in ]
[ a namespace when /proc was mounted with subset=pid ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-27 21:27:02 +11:00
Jim Warner
95990dceb1 top: just trade an assignement for a manifest constant
The assignment was originally created to reduce length
of one line of code (i.e. for readability). But we can
achieve this objective without adding executable code.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-27 21:27:02 +11:00
Jim Warner
787615d8da top: tweak a couple task_show() macros for consistency
There was a potential problem with these macros should
that '#define SCROLLVAR_NO' be active and they were to
appear in an 'if' statement (like is necessary for the
master branch version of top under that EU_CMD label).

[ now they're always usable without requiring an ';' ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-17 18:23:30 +11:00
Jim Warner
2c12f1f295 top: let's eliminate some additional compiler warnings
This patch eliminates those warnings referenced below.
They are sometimes associated with an obscure #define.

We'll also corrrect one header file function prototype
so it will aggree with the actual function definition.

Reference(s):
top.c: In function 'adj_geometry':
top.c:1874:20: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
 1874 |    if (Screen_cols < DOUBLE_limit) Curwin->rc.double_up = 0;
      |                    ^
top.c: In function 'zap_fieldstab':
top.c:2359:26: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
 2359 |    if (wtab[EU_CPN].wmin < digits) {
      |                          ^
top.c:2365:26: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
 2365 |    if (wtab[EU_NMA].wmin < digits) {
      |                          ^
top.c: In function 'keys_summary':
top.c:5128:45: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
 5128 |          if (w->rc.double_up && Screen_cols < DOUBLE_limit) {
      |                                             ^
top.c: In function 'sum_tics':
top.c:5605:22: warning: unused variable 'num_syst' [-Wunused-variable]
 5605 |    int ix, num_user, num_syst;
      |                      ^~~~~~~~
top.c:5605:12: warning: unused variable 'num_user' [-Wunused-variable]
 5605 |    int ix, num_user, num_syst;
      |            ^~~~~~~~

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-17 18:23:30 +11:00
Jim Warner
0847ea8360 top: attempt to clarify the 'iokey' parameter meanings
The 'iokey' function's parameter 'action' was utilized
with literal numbers in the calling functions. So this
change will replace those literal numbers with #define
constants which, one hopes, will clarify their impact.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-02-17 18:23:30 +11:00
Jim Warner
bc8b5a06b8 top: eliminate the potential warnings '-Wsign-compare'
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-31 18:10:48 +11:00
Jim Warner
d1c6a69a61 top: avoid a potential warning '-Wmaybe-uninitialized'
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-31 18:10:48 +11:00
Jim Warner
b9b0f408b8 top: avoid a possible warning '-Wimplicit-fallthrough'
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-31 18:10:48 +11:00
Jim Warner
1387c7f84b top: add visual clue when focus toggle ('F') is active
When in forest view mode, that focus toggle ('F') is a
useful tool occasionally. But, if a focused parent has
enough cloned siblings to exceed screen rows, it could
be hard to remember that such a toggle remains active.

So, this patch will provide a subtle visual clue added
to the leftmost position in the COMMAND column. Now if
the focus toggle was active, regardless of total tasks
affected, the users will always know when it's active.

Reference(s):
. -7/24/21, introduced new focus toggle
commit 3e922e671d
. 09/23/21, ensure focused tasks stay focused
commit 69978e3650

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:26:17 +11:00
Jim Warner
99c1f0578f top: correct one source comment plus one man page oops
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:26:17 +11:00
Jim Warner
44ca06f1a0 top: eliminate every warning for '-Wformat-truncation'
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-13 19:34:39 +11:00
Jim Warner
91ffe81734 misc: fixed several inconsistencies in email addresses
[ you wouldn't believe how many back-and-forths were ]
[ involved in Craig convincing me there were several ]
[ inconsistencies. i am so dense sometimes (often?). ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-08 07:15:59 +11:00
Craig Small
c83cd6e6c0 top: Fix my email address
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-01-07 19:29:23 +11:00
Jim Warner
cbff1dd106 top: bust up that overly large 'summary_show' function
Over the years the summary_show function has increased
from around 77 lines of code & comments to its current
size of 243 lines. This is well beyond an ideal length
of available screen rows. So this patch will split it.

We'll take the cpu and memory duties and make separate
functions out of them. Of course, this will incur some
additional call overhead but, given current cpu/memory
logic, any such increase really becomes insignificant.

Now summary_show's a svelte 57 lines of code/comments.

[ this is like what was done to that do_key function ]
[ a decade ago except overhead of new function calls ]
[ plus table lookup was even less of a concern since ]
[ a human was involved, not normal iterative output. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-07 19:19:15 +11:00
Jim Warner
0e744d3656 top: provide for avoiding task focus ('F') distortions
In the patch referenced below the focus task logic was
improved to ensure that newly cloned tasks 'above' the
focused task did not force an effect like the up arrow
key. That commit also acknowledged that when some task
'above' ended, it *would* act like the down arrow key.

Well, with this commit a task ending 'above' a focused
task no longer distorts the focus. That's assuming the
new '#define FOCUS_HARD_Y' is specified plus the total
focused tasks does not exceed the current screen rows.

Thus, the manual scrolling with up and down arrow keys
is allowed when the total focused exceeds screen rows.

[ but keep in mind that when a focused task has been ]
[ hardened some otherwise useful toggles will not be ]
[ available. keystrokes like 'v' and even 'F' itself ]
[ can not be applied to another task with no scroll. ]

Reference(s):
. Sep, 2021 - 'focus' logic improved
commit 69978e3650

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-07 19:19:15 +11:00
Jim Warner
afdd4690fc misc: amend the man page & source file copyright dates
This just updates the copyright dates in the documents
where I was already represented. Others are unchanged.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-07 19:19:15 +11:00
Jim Warner
d79157db51 top: make the __LINE__ usage and whitespace consistent
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-12-20 21:38:16 +11:00
Jim Warner
9b24a423b1 top: touch up that code for proc mounted as subset=pid
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-12-20 21:38:16 +11:00
Jim Warner
16145af663 top: adapt for running with proc mounted as subset=pid
As the issue cited below illustrates, a pids namespace
with proc mounted as subset=pid denies our library any
access to non-task data. In top's case, the result was
a fatal error message which involved "cpu statistics".

With this patch top will now assume an error involving
global cpu (stat) or memory (meminfo) data means we're
running under a restricted pids namespace. As such, an
attempt will be made to still display task level data.

[ if our assumption is incorrect, it's of no matter. ]
[ instead of a fatal error, we'll still try to offer ]
[ a user some minimally useful bit of functionality. ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/227
https://www.freelists.org/post/procps/three-for-newlib,1
. 1st cut at subset=pid
commit bcb837b8c7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-12-17 07:21:51 +11:00
Jim Warner
957b74292f ps,top: convert 'PIDS_PROCESSOR' into a signed integer
Not only does that library tweak help to simplify some
top code, but now that ps snprintf fmtstr will finally
be accurate. That is two birdies with a single pebble!

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-12-16 20:50:07 +11:00