]> granicus.if.org Git - procps-ng/log
procps-ng
2 years agotop: try avoiding the edge of a 'divide by zero' cliff <=== port of newlib 5f9185e0
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: try avoiding the edge of a 'divide by zero' cliff <=== port of newlib 5f9185e0

______________________________ original newlib message
----------------------------------- ( minus git hash )

Darn, after testing on some older, out of date distros
I was embarrassed to find some awful code I created in
the commit shown below. I was rewarded with some 'nan'
floating point values and 'inf' computational results.

Reference(s);
. a missed opportunity to repent
commit ........................................
. true source of my original sin
commit ........................................

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: fix 'TOG4_MEM_1UP' if two abreast summary display <=== port of newlib 124f26a4
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: fix 'TOG4_MEM_1UP' if two abreast summary display <=== port of newlib 124f26a4

The 'unrelated' note reflected in the original message
doesn't apply since we already used that correct name.

______________________________ original newlib message

If one per line display of Mem/Swap data was forced by
this #define, screen width was not fully exploited for
graph mode. Rather, those graphs were scaled just like
they would be if aligned with a nonexistent separator.

With this commit, those graphs will expand to fill the
screen width (or be limited by the maximum of '100' ).

[ and in unrelated news a variable used in do_memory ]
[ was changed for consistency. it doesn't affect the ]
[ the results since a part1 of swap was always zero. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: enhance memory graphs two abreast summary display <=== port of newlib 602146a6
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: enhance memory graphs two abreast summary display <=== port of newlib 602146a6

______________________________ original newlib message

This patch introduces a new #define TOG4_MEM_FIX which
serves to turn off the new feature it also implements.

The feature, on by default, provides a flexible memory
graph approach which strives to always keep its visual
separator in alignment with cpu separators seen above.

Below is a summary of the algorithm implementing this:

1) First, ascertain the widest graph which corresponds
to the largest number of cpu graphs but doesn't exceed
maximum allowable graph width (i.e. GRAPH_length_max).

2) Next, apply that to the graphed 'Mem' portion which
is likely to remain entirely visible. However, it will
grow or shrink depending on total adjacent cpu graphs.

3) Last, the same width is used for the 'Swap' portion
but that graph is considered sacrificial and very well
could be truncated depending on the width of a screen.

[ along the way, when the cpu graphs revert to their ]
[ abbreviated form, the memory graphs will also show ]
[ an abbreviated prefix. in this way the widths will ]
[ also be maximized, reducing potential distortions. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: cosmetic changes with two abreast summary display <=== port of newlib bf916fdf
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: cosmetic changes with two abreast summary display <=== port of newlib bf916fdf

______________________________ original newlib message

This commit will change some comments, adjust a little
whitespace but mostly rename some #define identifiers.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: distinct separator if two abreast summary display <=== port of newlib 96153c0f
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: distinct separator if two abreast summary display <=== port of newlib 96153c0f

______________________________ original newlib message

When displaying detailed memory statistics two abreast
data for the lines are less than those for cpus. So we
can exploit such a difference to provide a distinctive
separator. This may help separating cpu & memory data.

[ in truth, this happened before this patch. what we ]
[ are doing now is polishing that accidental feature ]
[ and placing it under the control of a conditional. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: harden detailed stats two abreast summary display <=== port of newlib e5386f1f
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: harden detailed stats two abreast summary display <=== port of newlib e5386f1f

______________________________ original newlib message

When displaying detailed cpu statistics, as opposed to
those scalable graphs, only two per line can be shown.

Therefore, if we are showing a detail version, our '4'
toggle must prematurely revert to single mode display.

Conversely, the 't' toggle must also turn off that '4'
toggle rather than try to print more than 2 abreast if
we're currently executing in detailed statistics mode.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: refined memory graphs two abreast summary display <=== port of newlib 5c5bff39
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: refined memory graphs two abreast summary display <=== port of newlib 5c5bff39

______________________________ original newlib message

When more than two cpus are displayed per summary area
line in graph form, those memory graphs were scaled to
that same width for consistency & aesthetics. However,
they probably shouldn't have been reduced to less than
terminal width due to a resulting loss of information.

[ after all, detailed memory stats are never reduced ]

So now, supporting logic was refactored to behave just
as it did before the 4 toggle was expanded beyond '1'.

[ the changes impact the 2 memory graphs exclusively ]

Reference(s):
https://www.freelists.org/post/procps/top-enhancements-2-bugs-swatted,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: additional tweaks for two abreast summary display <=== port of newlib 3543172d
Jim Warner [Mon, 19 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: additional tweaks for two abreast summary display <=== port of newlib 3543172d

______________________________ original newlib message

This patch just supplements the previous series with a
few minor tweaks representing some diverse objectives:

. a recent date for man page (which i always overlook)

. improved length calculations to maximize graph width

. a proper response to platforms with less than 8 cpus

. more consistency and readability with one blank line

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: top now has more than two abreast summary display <=== port of newlib fd529e96
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
doc: top now has more than two abreast summary display <=== port of newlib fd529e96

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: implemented more than two abreast summary display <=== port of newlib 248efdf1
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: implemented more than two abreast summary display <=== port of newlib 248efdf1

______________________________ original newlib message

Well, here it is. This is what the preceding series of
commits was leading to: an ability to show up to eight
cpus per Summary Area line. In reality, a self imposed
limit of four cpus on such lines seems more realistic.

In any case, the new capability could also be employed
along with that '!' toggle which consolidates adjacent
cpus into a solitary graph. When used together the '4'
and '!' toggles should accommodate any number of cpus.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: prepare for more than two abreast summary display <=== port of newlib 1c802890
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: prepare for more than two abreast summary display <=== port of newlib 1c802890

______________________________ original newlib message

I guess the cat's out of the bag with the prior commit
message. It mentioned the objective of displaying more
than the current two cpu graphs on summary area lines.

On the way to that objective, this patch just prepares
our battlefield for the actual implementation in which
up to 8 individual cpu graphs will be shown on 1 line.

[ no logic has been impacted with this commit. we're ]
[ just adding one manifest constant, trading several ]
[ identifiers and updating some comments so the next ]
[ commit might be just a little bit more manageable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: better graphic scaling in cpu/mem summary display <=== port of newlib 8c69e66a
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: better graphic scaling in cpu/mem summary display <=== port of newlib 8c69e66a

______________________________ original newlib message

This program has always been sensitive to the width of
a terminal/console. The detailed cpu/memory statistics
plus all of those full screen replacement windows were
designed to fit within some 80 column, 24 row display.

When a user narrowed a gui terminal to less than those
dimensions, top would simply truncate the data to fit.
However, when displaying cpu/mem graphs instead of the
detailed statistics such truncation was not justified.
After all, such graphs were already scaled to 80 cols.

Henceforth, when in graph mode, truncation won't occur
until the graphs will no longer fit within 10 columns.

[ can you keep a secret? this change is really being ]
[ made in anticipation of showing more than just two ]
[ cpu graphs in the summary area on each screen row! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: refactor graph support of cpu/mem summary display <=== port of newlib 2d5b51d1
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: refactor graph support of cpu/mem summary display <=== port of newlib 2d5b51d1

______________________________ original newlib message

The logic (illogic?) in the sum_tics() and do_memory()
functions has grown to become almost unfathomable over
time. Additionally, though perhaps not apparent in the
code, many steps are duplicated within those routines.

So, this patch refactors all the summary graph support
to consolidate duplicated code and (hopefully) make it
more understandable with an eye to future maintenance.

[ additionally, that show_special guy's workload has ]
[ been reduced by eliminating any special directives ]
[ previously embedded in some cpu graphs even though ]
[ a cpu may have been idle during the last interval. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: eliminate that 'TOG4_NOTRUNC' compile conditional <=== port of newlib 08d0f377
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: eliminate that 'TOG4_NOTRUNC' compile conditional <=== port of newlib 08d0f377

______________________________ original newlib message
----------------------------------- ( minus git hash )

When 2 abreast cpu display was introduced, the minimum
screen width was 160 columns so as to avoid (minimize)
truncation. Later that was reduced to 80 columns while
keeping the original minimum as a compile conditional.

In preparation for (virtually) eliminating these width
restrictions in a future patch this #define's history.

Reference(s):
. May, 2020 - introduced #define TOG4_NOTRUNC
commit ........................................
. May, 2020 - introduce 2 abreast display
commit ........................................

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: eliminate that 'TOG4_NOFORCE' compile conditional <=== port of newlib d9c45988
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: eliminate that 'TOG4_NOFORCE' compile conditional <=== port of newlib d9c45988

______________________________ original newlib message
----------------------------------- ( minus git hash )

When two abreast display was introduce, in that commit
shown below, this #define provision was also added. It
actually was an artifact left from program development
and never made much sense in a real world application.

If activated it would make the '4' toggle appear to be
broken since it would only take affect if a user first
activated individual cpu display (the '1' toggle off).
And there was no error message offered to those users.

So, this questionable #define is now being eliminated.

Reference(s):
. May, 2020 - introduce 2 abreast display
commit ........................................

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: fix an improper behavior following a SIGWINCH bug <=== port of newlib 9d999370
Jim Warner [Mon, 12 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: fix an improper behavior following a SIGWINCH bug <=== port of newlib 9d999370

______________________________ original newlib message
----------------------------------- ( minus git hash )

When top was made more responsive to keyboard input in
that commit referenced below, his previous response to
a SIGWINCH was upset. Formerly, that display integrity
was restored with the next refresh cycle. But, without
this patch, one must strike some key to accomplish it.

[ in truth, this patch vastly improves that sigwinch ]
[ response. whereas before, although integrity would ]
[ be restored automatically, it did not happen until ]
[ the next regular refresh. now it is instantaneous! ]

Reference(s):
. May, 2022 - made more responsive to kdb input
commit ........................................

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: eliminate a potential abend when exiting 'A' mode <=== port of newlib 80e2a7a6
Jim Warner [Wed, 27 Jul 2022 05:00:00 +0000 (00:00 -0500)]
top: eliminate a potential abend when exiting 'A' mode <=== port of newlib 80e2a7a6

______________________________ original newlib message
----------------------------------- ( minus git hash )

In that issue cited below, Tyson Nottingham identified
a potential abend which was associated with 'alternate
display mode' plus that troublesome 'mkVIZrow1' macro.
He also offered a perfectly adequate fix for that bug.

I refer to that macro as troublesome since it's now so
widely used and sometimes (by design) causes 'begtask'
to go negative (invalid). And now I found yet one more
place where it should have been used but wasn't ('f').

It's also troublesome as evidenced by some git history
listed below. Heck, there was even a commit addressing
the same symptoms (alternate display mode abend) which
Tyson suffered. Clearly, the current design is flawed.

So, with those two issues in mind, I've refactored the
approach to maintaining a visible task in the 1st row.
Henceforth, a 'mkVIZrow1' macro will be issued in only
two places: once at startup and after most keystrokes.

Such an approach likely results in additional calls to
the 'window_hlp' routine that aren't really necessary.
But, it provides a cleaner design less prone to errors
in the future. Besides, such additional overhead would
only be incurred when interacting with the user. Thus,
new costs are of no concern and will never be noticed.

Reference(s):
. Tyson Nottingham reported problem
https://gitlab.com/procps-ng/procps/-/issues/245
. Jun, 2018 - visible row 1 tasks first addressed
commit ........................................
. Jun, 2018 - adressed edge case, new bugs created
commit ........................................
. Sep, 2018 - additional edge case addressed
commit ........................................
. May, 2021 - some abends fixed, new error created
commit ........................................
. Jun, 2021 - try to prorect against future errors
commit ........................................
. Sep, 2021 - integrate mkVIZ & 'focused' tasks
commit ........................................

Discovered by: Tyson Nottingham
Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: make function prologue the same as newlib version
Jim Warner [Wed, 27 Jul 2022 05:00:00 +0000 (00:00 -0500)]
top: make function prologue the same as newlib version

The change occurred under the newlib branch in a patch
that couldn't be ported dealing with MEMINFO_MEM_USED.

That required a library change whereas this is frozen.

Reference(s):
. Jun, 2022 - newlib branch change
commit 047d16ccfda6638eda78f56b67def196a2002b6f

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: if line editing, account for invisible characters <=== port of newlib b0adacf1
Jim Warner [Mon, 27 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: if line editing, account for invisible characters <=== port of newlib b0adacf1

______________________________ original newlib message

If we're deleting a character or operating in overtype
mode, we must account for the potential of 'invisible'
characters. When one follows any character about to be
deleted or replaced both multi-byte sequences must go.

Without this change, there exists the possibility that
top might report some error where no error is apparent
to the user. For example, with 'other filtering' (o/O)
the user could see "unrecognized field name 'COMMAND'"
where the quoted column name appears perfectly normal.

Or maybe a sequences like the 'combining acute accent'
gets applied to an existing character instead of being
deleted as one expects when its parent was eliminated.

So, henceforth whenever any character is being deleted
we will now check for a following 'invisible' sequence
then eliminate it along with that preceding character.

[ admittedly, these scenarios are very rare yet they ]
[ may occur, especially when recalling some previous ]
[ multi-byte strings for editing. and, since we will ]
[ be interacting with a user, performance won't be a ]
[ factor so extra checks for a zero wcwidth is fine. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: adjust the man page alignment for 'Ctrl' commands <=== port of newlib 89200784
Jim Warner [Sun, 26 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: adjust the man page alignment for 'Ctrl' commands <=== port of newlib 89200784

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: afford another level of protection for line input <=== port of newlib 757a3452
Jim Warner [Sun, 26 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: afford another level of protection for line input <=== port of newlib 757a3452

______________________________ original newlib message

This commit just provides the final protection against
possible screen corruption when processing line input.

[ such corruption was limited to the input line only ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: adjust some parenthesis for correct '^N' behavior <=== port of newlib 3c7f8199
Jim Warner [Mon, 20 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: adjust some parenthesis for correct '^N' behavior <=== port of newlib 3c7f8199

______________________________ original newlib message

Some kdeinit tasks have a large environment consisting
mostly of nulls which were then followed by one or two
printable characters. Such strange environments should
not be shown with that 'not applicable' (n/a) notation
even though that first string vector is equal to '\0'.

I thought I had covered such a contingency but, due to
a misplaced right parenthesis, that '^N' bottom window
could see 'n/a' + a bunch of spaces + printable stuff.

Well, that won't happen anymore with this tiny change.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: make 'n/a' (not applicable) notation translatable <=== port of newlib daaf634e
Jim Warner [Mon, 20 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: make 'n/a' (not applicable) notation translatable <=== port of newlib daaf634e

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agoNEWS: acknowledge that utf8 multi-byte character input <=== port of newlib 2282c74c
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
NEWS: acknowledge that utf8 multi-byte character input <=== port of newlib 2282c74c

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: enable processing utf8 multi-byte character input <=== port of newlib c20fef1d
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: enable processing utf8 multi-byte character input <=== port of newlib c20fef1d

______________________________ original newlib message

This program was well equipped to properly handle utf8
multi-byte characters - except for one important area!

If users typed any unicode character (shift+ctrl+u) or
pasted a utf-8 multi-byte string as a response to some
input prompt, those characters would simply be ignored
since they would not pass the internal 'isprint' test.

Well, now we can handle such data while preserving all
line editing provisions such as insertions, deletions,
destructive backspace, prior line recall (up/down) and
those all important cursor left plus right arrow keys.

[ we even support overtype mode for multi-byte stuff ]
[ even though our gui emulator will not let us alter ]
[ the cursor as confirmation (as we do at a console) ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: provide for visual hint when overtype mode active <=== port of newlib 970a3dc9
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: provide for visual hint when overtype mode active <=== port of newlib 970a3dc9

______________________________ original newlib message

Given that we won't always be able to alter the cursor
shapes (from underscore to block) if in input overtype
mode, this commit will at least provide a visual clue.

[ while this libvte quirk will impact gnome-terminal ]
[ and likely others, we're able to change the cursor ]
[ shape from underscore to block at a linux console. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: avoid premature forced loss of that bottom window <=== port of newlib f40fc402
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: avoid premature forced loss of that bottom window <=== port of newlib f40fc402

______________________________ original newlib message
----------------------------------- ( minus git hash )

In the commit shown below the bottom window was forced
off if a full screen replacement function was invoked.
It did so by setting Frames_signal after calling those
routines from the keys_global function. However, there
was sometimes a possibility such action was premature.

At least two of those full screen replacement routines
may issue an error message & return without corrupting
the screen. As such, forcing off that bottom window is
totally unnecessary. It therefore should be preserved.

So this commit just moves the setting of Frames_signal
to the full screen replacement routines when possible.

Reference(s):
. May, 2022 - bottom window forced off for some
commit ........................................

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: acknowledge the top 'message log' display ability <=== port of newlib 60bac2b5
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
doc: acknowledge the top 'message log' display ability <=== port of newlib 60bac2b5

______________________________ original newlib message

[ along the way, we'll fix-up the section 4 commands ]
[ summary which has gotten a little outdated lately. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: provides a new user 'message log' display ability <=== port of newlib 3901dcb9
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: provides a new user 'message log' display ability <=== port of newlib 3901dcb9

______________________________ original newlib message

Messages issued by top will be displayed for only 1.25
seconds. And while this length of time would appear to
be acceptable (given the absence of complaints), there
will be times when a specific message might be missed.

So, this commit offers users the opportunity to recall
up to 10 of the most recent messages that were issued.

[ we'll just exploit top's new bottom window feature ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: the bottom 'window' headings are now translatable <=== port of newlib 20859f6f
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: the bottom 'window' headings are now translatable <=== port of newlib 20859f6f

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: remove the 'BOT_MENU_YES' prototype demonstration <=== port of newlib dedcfa76
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: remove the 'BOT_MENU_YES' prototype demonstration <=== port of newlib dedcfa76

______________________________ original newlib message

Now that a potential use of that bottom 'window' for a
menu has been demonstrated, we'll remove such clutter.

[ after all, the prior commit cautioned against text ]
[ made conditional which might also be translatable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: don't make translatable text subject to a #define <=== port of newlib b587d946
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: don't make translatable text subject to a #define <=== port of newlib b587d946

______________________________ original newlib message

While it is acceptable to make text usage conditional,
one must never make the text itself conditional. After
all, the translators must be presented with all of the
text so the opportunity to translate it is never lost.

[ one wonders who the idiot was that did this anyway ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: cleanup of miscellaneous stuff from prior commits <=== port of newlib daedcb97
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: cleanup of miscellaneous stuff from prior commits <=== port of newlib daedcb97

______________________________ original newlib message
----------------------------------- ( minus git hash )

Fix some errors introduced in the commits shown below.

Reference(s):
. Apr, 2022 - 'keys_global' missed redundancy
commit ........................................

. Apr, 2022 - added extraneous comma in help text
commit ........................................

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: enable bottom 'window' multi-byte char capability <=== port of newlib 723b418c
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: enable bottom 'window' multi-byte char capability <=== port of newlib 723b418c

______________________________ original newlib message

If the special bottom 'window' routines remain unaware
of potential multi-byte characters, that heading could
be truncated prematurely and unnecessary blank line(s)
added to the reserved rows at the bottom of a display.

So, in both cases, this patch will now account for any
difference between string lengths and display columns.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: rework bottom 'window' logic to reduce redundancy <=== port of newlib ef1d82cf
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: rework bottom 'window' logic to reduce redundancy <=== port of newlib ef1d82cf

______________________________ original newlib message

This patch attempts to reduce the proliferation of the
bottom window support routines by combining the 'misc'
with 'item' functions. Along the way we can now rename
those two 'pick' functions 'menu' while keeping proper
alphabetic order among all the bottom window routines.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: extend shift+tab (back_tab) navigation to console <=== port of newlib e99c5abb
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: extend shift+tab (back_tab) navigation to console <=== port of newlib e99c5abb

______________________________ original newlib message

Really, just extend shift+tab navigation to some linux
consoles (or maybe most consoles). However, there were
some consoles where shift+tab always yields just '\t'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: apply a special emphasis with some focus elements <=== port of newlib 1dd27ba3
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: apply a special emphasis with some focus elements <=== port of newlib 1dd27ba3

______________________________ original newlib message

Since top now uses string vectors for two items in the
new focus window (cmdline & environ), there is no real
use for that 'separator' specified at toggle time. So,
this commit will find a new use for what is the space.

Henceforth, when a user is navigating using the tab or
backtab keys, should a strv element with focus contain
embedded space(s), it will be emphasized & highlighted
using the current window's message color (capclr_msg).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: some imbedded literals are now manifest constants <=== port of newlib 304c4370
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: some imbedded literals are now manifest constants <=== port of newlib 304c4370

______________________________ original newlib message

A commit that changes no code but, hopefully, helps to
better document where and how such literals were used.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: modify 'focus' strv function to display 'n/a' too <=== port of newlib fc3ba30a
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: modify 'focus' strv function to display 'n/a' too <=== port of newlib fc3ba30a

______________________________ original newlib message

This commit just brings that 'bot_focus_strv' function
up to the same standard as the vanilla 'bot_focus_str'
guy. Namely, if there is no cmdline or environ for any
process, that bottom window will now display an 'n/a'.

[ with the nature of those string vectors, it wasn't ]
[ the same simple process found for regular strings. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: extend 'focus' navigation to shift+tab (back_tab) <=== port pf newlib 434e2242
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: extend 'focus' navigation to shift+tab (back_tab) <=== port pf newlib 434e2242

______________________________ original newlib message

Some of those bottom windows grow quite large, as with
the firefox environment. If one is navigating the data
using the tab key, it can be very inconvenient when an
element should be reexamined but that focus has moved.

Therefore, this commit will support the 'back_tab' key
which is a standard combination of the shift+tab keys.

Now a user can easily backup up to any missed element,
assuming a terminal emulator honors that terminfo key.

[ a gui emulator typically will honor the 'back_tab' ]
[ terminfo string, whereas a linux console does not. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: be more careful with memcpy length specifications <=== port of newlib c00d09ed
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: be more careful with memcpy length specifications <=== port of newlib c00d09ed

______________________________ original newlib message

Using 'mempcpy' was a mistake where plain old 'memcpy'
was appropriate. More importantly, the careless length
specified resulted in a SEGV under some circumstances.

[ namely, it occurred under a multi-threaded top and ]
[ the top program itself as focus + CtrlN 'environ'. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: modify 'Ctrl' bottom window 'str' use with 'strv' <=== port of newlib 73b4f113
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: modify 'Ctrl' bottom window 'str' use with 'strv' <=== port of newlib 73b4f113

______________________________ original newlib message

After satisfying increased buffer size in the previous
patch, I decided to improve the highlight accuracy for
both the command lines plus the environment variables.

Since they both may contain elements which themselves
include embedded spaces, to accomplish this goal, one
must trade vanilla strings for string vectors instead.

[ at last such library items have now been justified ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: needed 'Ctrl' bottom window fixes were discovered <=== port of newlib da36ff2b
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: needed 'Ctrl' bottom window fixes were discovered <=== port of newlib da36ff2b

______________________________ original newlib message

As it turns out, some of the 'environ' strings are big
enough to overrun the initial buffer sizes. And, while
no real harm was done (other than to silently truncate
the output), this patch will increase the buffer size.

While we're at it. we will normalize a few more buffer
declarations along with correcting a couple typos too.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: man page adjusted for response to keyboard inputs <=== port of newlib b8f79a7b
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
doc: man page adjusted for response to keyboard inputs <=== port of newlib b8f79a7b

______________________________ original newlib message
----------------------------------- ( minus git hash )

[ and along the way, those 2 newest namespace fields ]
[ are now mentioned under that same 'X' command part ] <=== hey, we don't got them here!
[ this commit already changed for improved response. ]

[ they should have been included in the patch below. ]

Reference(s):
commit ........................................

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: program is now more responsive to keyboard inputs <=== port of newlib 3ea1bc77
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: program is now more responsive to keyboard inputs <=== port of newlib 3ea1bc77

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: detail 'Ctrl' bottom window namespaces plus focus <=== port of newlib 381af1af
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
doc: detail 'Ctrl' bottom window namespaces plus focus <=== port of newlib 381af1af

______________________________ original newlib message

[ along the way we will restore '^R' to keys summary ]
[ plus correct a leftover reference to 'Ctrl-V' too. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: extend 'Ctrl' bottom window for 'memu' selections <=== port od newlib 659590b0
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: extend 'Ctrl' bottom window for 'memu' selections <=== port od newlib 659590b0

______________________________ original newlib message

This commit adds a prototype for a potential extension
of that tabbed bottom window capability. It introduces
a 'menu' which then provides for users' selections. It
does not actually do anything meaningful and will only
be enabled with the new #define called 'BOT_PICK_YES'.

[ since it's just a proof of concept, no attempt has ]
[ been made to add the usual NLS translation support ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: extend 'Ctrl' bottom window for focus via tab key <=== port of newlib de22afc4
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: extend 'Ctrl' bottom window for focus via tab key <=== port of newlib de22afc4

______________________________ original newlib message

This commit introduces the 'tab' key which can be used
to highlight individual elements in that bottom 'Ctrl'
window. This can really help when reviewing such data.

[ note, normal ongoing monitoring continues unabated ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: expand 'Ctrl' bottom window to display other data <=== port of newlib c46a60d9
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: expand 'Ctrl' bottom window to display other data <=== port of newlib c46a60d9

______________________________ original newlib message

This commit adds support for displaying the namespaces
in top's separate bottom 'Ctrl' window. Along the way,
the plumbing is now in place to extend this capability
to other data (if we don't run out of '^' keystrokes).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: rename 'Ctrl' bottom window routines and relocate <=== port of newlib ad17ffe6
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: rename 'Ctrl' bottom window routines and relocate <=== port of newlib ad17ffe6

______________________________ original newlib message

This patch will just set the stage for the next commit
where we'll be adding the capability to display things
that sometimes may necessitate multiple library items.

In that effort we will be adding several new routines.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: turn off the 'Ctrl' bottom window with 1 more key <=== port of newlib 3f068a66
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: turn off the 'Ctrl' bottom window with 1 more key <=== port of newlib 3f068a66

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: fix a bug from when 'Ctrl' window was made sticky <=== port of newlib 793f3e85
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: fix a bug from when 'Ctrl' window was made sticky <=== port of newlib 793f3e85

______________________________ original commit message
----------------------------------- ( minus git hash )

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 ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: avoid library shame with refactored 'Ctrl' window <=== port of newlib bc4b499e
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: avoid library shame with refactored 'Ctrl' window <=== port of newlib bc4b499e

       [ sorry, but under this master branch ]
       [ the whole next narrative is frankly ]
       [ mostly pure unadulterated bullshit. ]

______________________________ original newlib message

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>
2 years agotop: turn off the 'Ctrl' bottom window after some keys <=== port of newlib d66c1f39
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: turn off the 'Ctrl' bottom window after some keys <=== port of newlib d66c1f39

______________________________ original newlib message

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>
2 years agotop: allow sticky 'Ctrl' bottom window code by #define <=== port of newlib 16e202d2
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: allow sticky 'Ctrl' bottom window code by #define <=== port of newlib 16e202d2

______________________________ original newlib message

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>
2 years agodoc: adapt to the 'Ctrl' bottom window one changed key <=== port of newlib 54b949a1
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
doc: adapt to the 'Ctrl' bottom window one changed key <=== port of newlib 54b949a1

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: trade just 1 'Ctrl' bottom window key association <=== port of newlib 9ff5a4ff
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: trade just 1 'Ctrl' bottom window key association <=== port of newlib 9ff5a4ff

______________________________ original newlib message

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>
2 years agodoc: adapt to the 'Ctrl' bottom window sticky behavior <=== port of newlib ef27aea6
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
doc: adapt to the 'Ctrl' bottom window sticky behavior <=== port of newlib ef27aea6

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: make the new 'Ctrl' bottom window behavior sticky <=== port of newlib 0f2a755b
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: make the new 'Ctrl' bottom window behavior sticky <=== port of newlib 0f2a755b

______________________________ original newlib message

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>
2 years agotop: add a program name to 'Ctrl' bottom window header <=== port of newlib bad7f2a2
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: add a program name to 'Ctrl' bottom window header <=== port of newlib bad7f2a2

______________________________ original newlib message

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 <=== not in this branch, cookie
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>
2 years agodoc: add variable width data display without scrolling <=== port of newlib 6b24d11b
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
doc: add variable width data display without scrolling <=== port of newlib 6b24d11b

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: add variable width data display without scrolling <=== port of newlib fb32021e
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: add variable width data display without scrolling <=== port of newlib fb32021e

______________________________ original newlib message

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>
2 years agotop: eliminate the 'keys_global' redundant definitions <=== port of newlib 27f5904e
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: eliminate the 'keys_global' redundant definitions <=== port of newlib 27f5904e

[ can't implement Ctrl-R with AGNI, it ain't present ]

______________________________ original newlib message
--------------------------------------------- ( none )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agops: that restored aix behavior gets its ultimate tweak <=== port of newlib 5edeabbd
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
ps: that restored aix behavior gets its ultimate tweak <=== port of newlib 5edeabbd

______________________________ original newlib message

Now that this 'c' variable initial assignment has been
moved outside the looping code, there is no longer any
need to specifically check for space/comma when 'c' is
not '%'. So, let us eliminate those two lines of code.

[ i promise not to change this algorithm ever again! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: remove those winflags which restricted 'x' toggle <=== port of newlib ef8d1cb6
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: remove those winflags which restricted 'x' toggle <=== port of newlib ef8d1cb6

______________________________ original newlib message

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>
2 years agotop: raise %CPU maximum if large numbers of processors <=== port of newlib 7279cd8e
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: raise %CPU maximum if large numbers of processors <=== port of newlib 7279cd8e

______________________________ original newlib message

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>
2 years agotop: ignore the SIGHUP signal if running in batch mode <=== port of newlib 6aec3ec9
Jim Warner [Wed, 15 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: ignore the SIGHUP signal if running in batch mode <=== port of newlib 6aec3ec9

______________________________ original newlib message

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>
2 years agofix NEWS
Craig Small [Mon, 11 Apr 2022 06:39:49 +0000 (16:39 +1000)]
fix NEWS

2 years agosysctl: print dotted keys again
Craig Small [Sat, 9 Apr 2022 04:18:28 +0000 (14:18 +1000)]
sysctl: print dotted keys again

When the globbing update was put into sysctl, you could no longer
simply use the keys because one key could potentially be
multiple paths once the glob expansion occured.  Using the path
instead gave a unique output.

Except certain programs, such as salt, expected the output to use
the dotted path "kernel.hostname" and not "kernel/hostname".

We can no longer use the original key, so now for each path:
  Copy the path
  strip off /proc/
  convert all / to .

The sysctl testsuite was also updated to check for a few different
types of conversion failures.

References:
 commit 6389deca5bf667f5fab5912acde78ba8e0febbc7
 https://www.freelists.org/post/procps/some-procpsn4400-fixes,4
 https://repo.saltproject.io/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agops: that restored aix behavior is now even more robust
Jim Warner [Mon, 4 Apr 2022 05:00:00 +0000 (00:00 -0500)]
ps: that restored aix behavior is now even more robust

With the commit referenced below a nasty bug affecting
aix parsing was swatted. Beyond the bug, the logic was
enhanced to disallow commas in the format string since
they would otherwise be shown with their field's data.

However, there remained many characters other than ','
that could survive the edits to then be shown adjacent
to the data. Well, with this patch they won't anymore!

[ along the way we will no longer try to forgive the ]
[ use of a double '%%' prefix since that resulted in ]
[ display of one '%' and field code instead of data. ]

Reference(s):
. March, 2022 - restored aix bahavior
commit f0b7fd31db1e82b2a83f40541f8fbe0fe7b98ace

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agops: restore aix behavior while keeping an original fix
Jim Warner [Wed, 30 Mar 2022 19:00:00 +0000 (14:00 -0500)]
ps: restore aix behavior while keeping an original fix

[ since our'master' branch will suffer the same fate ]
[ this was ported from a patch created for 'newlib'. ]

-------------------------- original newlib commit text
-------------------------- (showing our master commit)

The commit shown below broke the aix behavior that Dr.
Fink recently reported. However, in the proposed patch
the old behavior, showing garbage when '%cpu' was used
with an invalid formatting option, would appear again.

So this patch, based on Werner's patch, goes the extra
distance to prevent that. Along the way we'll disallow
commas in the aix format str to prevent their display.

Reference(s):
https://www.freelists.org/post/procps/Procpsng-400-released-with-newlib,2
. Mar, 2022 - where aix bug was introduced
commit 05187e4f17fec226ca60595a7558f9a34750efb0

Prototyped-by: Dr. Werner Fink <werner@suse.de>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: add another tiny bit of robustness to rcfile code
Jim Warner [Tue, 15 Mar 2022 05:00:00 +0000 (00:00 -0500)]
top: add another tiny bit of robustness to rcfile code

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.

[ while the absence of this new check didn't produce ]
[ an error message, it would skip the initialization ]
[ of default values plus possible string extensions. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: do not add an extra line when rcfile is rewritten
Jim Warner [Tue, 15 Mar 2022 05:00:00 +0000 (00:00 -0500)]
top: do not add an extra line when rcfile is rewritten

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.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodoc: document catch-up of new scalable 'STARTED' field
Jim Warner [Fri, 11 Mar 2022 06:00:00 +0000 (00:00 -0600)]
doc: document catch-up of new scalable 'STARTED' field

[ the original newlib commit message(s) appear below ]
[ but 'cpu utilization' was not implemented to avoid ]
[ any library modifications and thus version impact! ]

------------------------------------- newlib patch ---
doc: updated with new 'start time' & 'cpu utilization'

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: squashed catch-up of new scalable 'STARTED' field
Jim Warner [Fri, 11 Mar 2022 06:00:00 +0000 (00:00 -0600)]
top: squashed catch-up of new scalable 'STARTED' field

[ the original newlib commit message(s) appear below ]
[ but 'cpu utilization' was not implemented to avoid ]
[ any library modifications and thus version impact! ]

--------------------------------- newlib patch #1 ---
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 ]

---------------------------------- newlib patch #2 ---
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 ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodoc: document 'scale_tics' catch-up for Ctrl-E scaling
Jim Warner [Thu, 10 Mar 2022 06:00:00 +0000 (00:00 -0600)]
doc: document 'scale_tics' catch-up for Ctrl-E scaling

[ the original newlib commit message(s) appear below ]

------------------------------------- newlib patch ---
doc: document 'scale_tics' function for Ctrl-E scaling

[ i also tweaked that 'STARTED' narrative just a bit ]
[ since its original wording implied the value could ]
[ change, whereas it's fixed when a task is started. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: squashed 'scale_tics' catch-up for Ctrl-E scaling
Jim Warner [Thu, 10 Mar 2022 06:00:00 +0000 (00:00 -0600)]
top: squashed 'scale_tics' catch-up for Ctrl-E scaling

[ the original newlib commit message(s) appear below ]

---------------------------------- newlib patch #1 ---
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.

---------------------------------- newlib patch #2 ---
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.

---------------------------------- newlib patch #3 ---
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.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: swat insidious bug with the %cpu' format specifier
Jim Warner [Wed, 9 Mar 2022 06:00:00 +0000 (00:00 -0600)]
ps: swat insidious bug with the %cpu' format specifier

[ the original newlib commit message(s) appear below ]

----------------------------------------- newlib patch
ps: swat insidious bug with the %cpu' format specifier

Whoa, my head really hurts but this commit should help
with a speedy recovery hopefully, after it is applied.

If the '%cpu' field is used as a format specifier with
that 'o' option, you will encounter a SIGSEGV if there
is also an invalid argument on that same command line.

For example, try 'ps/pscommand -o %cpu,x' with newlib.
With any format specifier other than the '%cpu', there
is an error message, as would happen with '-o pcpu,x'.

For a 3.3.17 version of ps, there's no abend. Instead,
the program will just display a bunch of gobbledygook.
This boo-boo was found to exist as far back as v3.3.0.

[ ok, i am starting to feel very much better already ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: trade that 'strncpy' for more efficient 'memccpy'
Jim Warner [Tue, 15 Feb 2022 06:00:00 +0000 (00:00 -0600)]
top: trade that 'strncpy' for more efficient 'memccpy'

This patch was prompted by the merge request for pgrep
referenced below. In top's case, any performance gains
will be minimal since the now defunct strncpy was only
employed for termcap rebuilds after interacting with a
user (+ 1 other non-termcap related user interaction).

[ golly, strncpy always calls at least two functions ]
[ but usually calls a total of 3. on the other hand, ]
[ memccpy will only call a maximum of two functions. ]

And thanks to Baruch Siach for these strncpy insights.

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/148

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: let's eliminate some additional compiler warnings
Jim Warner [Mon, 14 Feb 2022 06:00:00 +0000 (00:00 -0600)]
top: let's eliminate some additional compiler warnings

This patch eliminates those warnings referenced below.

[ the last error shown needed a little extra cleanup ]
[ for when that '#define SCROLLVAR_NO' is activated. ]

Reference(s):
top.c: In function 'adj_geometry':
top.c:1976:20: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
 1976 |    if (Screen_cols < DOUBLE_limit) Curwin->rc.double_up = 0;
      |                    ^
top.c: In function 'zap_fieldstab':
top.c:2436:26: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
 2436 |    if (wtab[EU_CPN].wmin < digits) {
      |                          ^
top.c:2442:26: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
 2442 |    if (wtab[EU_NMA].wmin < digits) {
      |                          ^
top.c: In function 'keys_summary':
top.c:5382:45: warning: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Wsign-compare]
 5382 |          if (w->rc.double_up && Screen_cols < DOUBLE_limit) {
      |                                             ^
top.c: In function 'task_show':
top.c:6306:13: error: expected ';' before 'else'
 6306 |             else
      |             ^~~~

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: attempt to clarify the 'iokey' parameter meanings
Jim Warner [Sun, 13 Feb 2022 06:00:00 +0000 (00:00 -0600)]
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>
3 years agotop: tweak the heck out of some command line help text
Jim Warner [Wed, 26 Jan 2022 06:00:00 +0000 (00:00 -0600)]
top: tweak the heck out of some command line help text

This patch began as just an attempt to make any option
which also included an argument a little more readable
by adding one space before the '=ARGUMENT' convention.

[ by the way, i don't agree with most of those other ]
[ procps-ng programs that use an '<arg>' convention. ]
[ it's too easily misread as an 'optional' argument. ]

[ top uses a convention like that found in coreutils ]
[ albeit now with one extra space before the equals. ]

In adjusting those arguments it was apparent that many
explanations already lined up nicely at the right hand
margin. So, this commit will force right-justification
with all explanations (as we do with commit messages).

[ and as a final challenge, for those options taking ]
[ an argument, that argument was repeated within the ]
[ explanation and made the rightmost item on a line. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: eliminate the potential warnings '-Wsign-compare'
Jim Warner [Tue, 25 Jan 2022 06:00:00 +0000 (00:00 -0600)]
top: eliminate the potential warnings '-Wsign-compare'

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: avoid a potential warning '-Wmaybe-uninitialized'
Jim Warner [Tue, 25 Jan 2022 06:00:00 +0000 (00:00 -0600)]
top: avoid a potential warning '-Wmaybe-uninitialized'

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: avoid a possible warning '-Wimplicit-fallthrough'
Jim Warner [Tue, 25 Jan 2022 06:00:00 +0000 (00:00 -0600)]
top: avoid a possible warning '-Wimplicit-fallthrough'

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: add visual clue when focus toggle ('F') is active
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
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):
. 07/28/21, introduced new focus toggle ('F')
commit bdd50fa2fc00edb51f6125334d2329fdce12c4ba
. 09/23/21, ensure focused tasks stay focused
commit d7e6c27a7944fbaa1493f207fd521bd59984c955

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: eliminate warnings for '-Wmisleading-indentation'
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: eliminate warnings for '-Wmisleading-indentation'

Reference(s):
. 01/08/22, newlib branch equivalent commit
commit 68995bee95d145f84c27849c47e4512da3f77a7e

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: eliminate every warning for '-Wformat-truncation'
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: eliminate every warning for '-Wformat-truncation'

Reference(s):
. 01/08/22, newlib branch equivalent commit
commit f05c78d174d3383afc3f71956c23e3e1e75bb2ed

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: repair several inconsistencies in email addresses
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: repair 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?). ]

Reference(s):
. 01/2022, newlib branch equivalent commits
commit 91ffe817343a43ac67a1a1ffaf1d02aca2760b11
commit c83cd6e6c01a51c12340472a59e507e835db9de0

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: bust up that overly large 'summary_show' function
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
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 195 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 31 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. ]

Reference(s):
. 01/03/22, newlib branch equivalent commit
commit cbff1d;d10645cb8c7fc55dda08b06fbafed05932

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: provide for avoiding task focus ('F') distortions
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
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):
. 01/03/22, newlib branch equivalent commit
commit 0e744d3656b1e0299f1083b7f7eabf60fb080f10
. 09/24/21, master branch 'focus' logic improved
commit d7e6c27a7944fbaa1493f207fd521bd59984c955

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: update the man page & source file copyright dates
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: update the man page & source file copyright dates

This just updates the copyright dates in the documents
within the top subdirectory only. Others are unchanged.

Reference(s):
. 01/01/22, newlib branch equivalent commit
commit afdd4690fc3dfa6b5b89ec7795870d8becf416ba

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: justify those header #define description comments
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: justify those header #define description comments

This commit is an example of what can happen when this
author is waiting around for the release of our newlib
& otherwise runs out of legitimate changes to be made.

[ on the other hand, such changes surely make us run ]
[ quite a bit more efficiently, if i am not mistaken ]

Reference(s):
. 09/14/21, newlib branch equivalent commit
commit 6049c13b4d9c26d20fd62899cca4e4525ba1b906

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: enabled arbitrarily large numbers in 'scale' guys
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: enabled arbitrarily large numbers in 'scale' guys

While experimenting with a new feature, wherein select
fields display the total upon request, the capacity of
the 'num' passed to some 'scale' guys became an issue.

So this commit will, with the compiler's help, put the
responsibility for converting the integer into a float
within the calling code (instead of the called logic).

Reference(s):
. 03/08/21, newlib branch equivalent commit
commit 62928cf4614314dfb99adba79240098f49487c6f

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: a silly change forcing right margin justification
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: a silly change forcing right margin justification

Reference(s):
. 01/11/21, newlib branch equivalent commit
commit 0cf6942be70817cc363c4ae4df99d56d3e317b71

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: allow setting variable width col scroll (1 vs. 8)
Jim Warner [Thu, 13 Jan 2022 19:13:13 +0000 (13:13 -0600)]
top: allow setting variable width col scroll (1 vs. 8)

The Inspection feature already offered an INSP_SLIDE_1
provision. This patch now offers similar extensions to
variable width column scrolling (assuming SCROLLVAR_NO
isn't defined). Such a provision was useful during the
development of some recent library UTF-8 enhancements.

Reference(s):
. 12/30/20, newlib branch equivalent commit
commit edce9ed61241146939473aaa80b7a469b7442cbf

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agofix uid/gid > 2^31
Todd Lewis [Mon, 25 Oct 2021 23:38:10 +0000 (19:38 -0400)]
fix uid/gid > 2^31

3 years agops: ignore SIGURG
Tommi Rantala [Mon, 11 Oct 2021 10:33:18 +0000 (13:33 +0300)]
ps: ignore SIGURG

Stop registering signal handler for SIGURG, to avoid ps failure if
someone sends such signal. Without the signal handler, SIGURG will
just be ignored.

  Signal 23 (URG) caught by ps (3.3.16).
  ps:ps/display.c:66: please report this bug

https://man7.org/linux/man-pages/man7/signal.7.html
https://www.freebsd.org/cgi/man.cgi?sektion=3&query=signal

3 years agotestsuite: Make test program compile on Hurd
Craig Small [Tue, 12 Oct 2021 20:56:39 +0000 (07:56 +1100)]
testsuite: Make test program compile on Hurd

procps fails to build from source due to usage of field si_int of struct
siginfo_t in lib/test_process.c which does not exist on GNU/Hurd.

Thanks to Svante Signell for the patch.

References:
 https://bugs.debian.org/987557

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotop: restore ending ']' when summary graphs are scaled
Jim Warner [Mon, 4 Oct 2021 05:00:00 +0000 (00:00 -0500)]
top: restore ending ']' when summary graphs are scaled

When a visual separator was added to 2 abreast summary
items in a recent commit, this bug was introduced. So,
from that earlier patch we'll revert one line of code.

The bug surfaced under an 80/even column terminal only
when that '4' toggle was off. With an an 81/odd column
screen, it existed in both single and 2 abreast modes.

[ this commit also goes the extra distance to ensure ]
[ two abreast mode maximizes available screen width. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>