]> granicus.if.org Git - procps-ng/log
procps-ng
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: refined memory graphs two abreast summary display
Jim Warner [Mon, 12 Sep 2022 18:13:13 +0000 (13:13 -0500)]
top: refined memory graphs two abreast summary display

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
Jim Warner [Mon, 12 Sep 2022 13:00:00 +0000 (08:00 -0500)]
top: additional tweaks for two abreast summary display

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
Jim Warner [Sat, 10 Sep 2022 05:00:00 +0000 (00:00 -0500)]
doc: top now has more than two abreast summary display

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: implemented more than two abreast summary display
Jim Warner [Sat, 10 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: implemented more than two abreast summary display

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
Jim Warner [Sat, 10 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: prepare for more than two abreast summary display

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
Jim Warner [Fri, 9 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: better graphic scaling in cpu/mem summary display

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
Jim Warner [Fri, 9 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: refactor graph support of cpu/mem summary display

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
Jim Warner [Thu, 8 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: eliminate that 'TOG4_NOTRUNC' compile conditional

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 be3dcaa842cb64859e356d350c17de34932e5f1b
. May, 2020 - introduce 2 abreast display
commit 59f5a37a247184b3009af963706ca68198067185

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

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 59f5a37a247184b3009af963706ca68198067185

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: fix an improper behavior following a SIGWINCH bug
Jim Warner [Wed, 7 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: fix an improper behavior following a SIGWINCH bug

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 3ea1bc779fb7ca5bf065a5ca620ec5b5823bc61c

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: address an 'uninitialised value' VALGRIND bug
Jim Warner [Wed, 7 Sep 2022 05:00:00 +0000 (00:00 -0500)]
library: address an 'uninitialised value' VALGRIND bug

Thanks to valgrind and his --track-origins=yes option,
the problem and solution was suggested as shown below.

[ and it was created in that commit referenced below ]

But, after attacking this problem by adding a memset()
call in pids.c, a 2nd valgrind oops, also shown below,
was encountered. The dynamically acquired 'cmd' again!

[ might help to explain why changes appear excessive ]

Reference(s):
. 1st valgrind discovery
==11111== Conditional jump or move depends on uninitialised value(s)
==11111==    at 0x13425D: stat2proc (readproc.c:582)
==11111==    by 0x137436: look_up_our_self (readproc.c:1613)
==11111==    by 0x132196: fatal_proc_unmounted (pids.c:1388)
==11111==    by 0x11BA4D: before (top.c:3580)
==11111==    by 0x127E10: main (top.c:7173)
==11111==  Uninitialised value was created by a stack allocation
==11111==    at 0x132165: fatal_proc_unmounted (pids.c:1381)

. Jul, 2022 - fatal_proc_unmounted refactored
commit 52bd019d8ca09ecfec34b5020eb7b8d612c315f8

. 2nd valgrind discovery
==22222== 16 bytes in 1 blocks are definitely lost
==22222==    by 0x4A0E60E: strdup (strdup.c:42)
==22222==    by 0x133D00: stat2proc (readproc.c:587)
==22222==    by 0x136E67: look_up_our_self (readproc.c:1613)
==22222==    by 0x131BC7: fatal_proc_unmounted (pids.c:1390)
==22222==    by 0x11B7C6: before (top.c:3580)
==22222==    by 0x127828: main (top.c:7173)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agonls: Update man-po for EIP updates v4.0.1rc1
Craig Small [Mon, 5 Sep 2022 07:50:54 +0000 (17:50 +1000)]
nls: Update man-po for EIP updates

References:
 commit 3fa04fa9471cc1020c8c7e534ef1d4fa500c90d6

2 years agonls: Update translations for ignore ancestors
Craig Small [Mon, 5 Sep 2022 07:46:40 +0000 (17:46 +1000)]
nls: Update translations for ignore ancestors

References:
 commit 4b44ab98c144dae099442e30a62966a7689818c6

2 years agodocs: add info on why eip and esp are zeroed out
Eduardo Damato [Fri, 26 Aug 2022 11:05:02 +0000 (08:05 -0300)]
docs: add info on why eip and esp are zeroed out

2 years agoImprove trace().
Rafael Kitover [Fri, 15 Oct 2021 04:40:03 +0000 (04:40 +0000)]
Improve trace().

Turn on trace() with the TRACE macro and remove the ## token paste
preprocessor operator which is unnecessary here and causes these errors:

ps/common.h:176:26: error: pasting "(" and ""ps_argv[thisarg] is %s\n""
does no t give a valid preprocessing token
.

Send trace output to STDERR.

Tracing can be enabled by adding TRACE to CPPFLAGS as follows:

./configure CPPFLAGS="-DTRACE"

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2 years agopgrep: Look at all ancestors in --ignore-ancestors
Chris Down [Wed, 31 Aug 2022 08:59:47 +0000 (09:59 +0100)]
pgrep: Look at all ancestors in --ignore-ancestors

Previously we mistakenly only checked one previous level of the
hierarchy.

Signed-off-by: Chris Down <chris@chrisdown.name>
2 years agomisc: Update NEWS/man date for pgrep -A
Craig Small [Wed, 31 Aug 2022 07:43:17 +0000 (17:43 +1000)]
misc: Update NEWS/man date for pgrep -A

Added NEWS item
Update pgrep.1 date

References:
 commit 4b44ab98c144dae099442e30a62966a7689818c6

2 years agonls: Update man translations for new library
Craig Small [Wed, 31 Aug 2022 07:40:50 +0000 (17:40 +1000)]
nls: Update man translations for new library

Library translations now use the new library and include
path.

References:
 commit 1502648ff9aef047286db2e03a3e1a872d40a0e2

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agopgrep: Add support for ignoring ancestors with -A/--ignore-ancestors
Chris Down [Wed, 10 Aug 2022 13:07:38 +0000 (14:07 +0100)]
pgrep: Add support for ignoring ancestors with -A/--ignore-ancestors

pgrep and friends naturally filter their own processes from their
matches. The same issue can occur when elevating with tools like sudo or
doas, where the elevating shim layers linger as a parent and are
returned in the results. For example:

    % sudo pkill -9 -cf someelevatedcmdline
    1
    zsh: killed     sudo pkill -9 -cf someelevatedcmdline

This is a situation we've actually seen in production, where some poor
soul changes how permission management works (for example with Linux's
hidepid option), needs to elevate a pgrep or pkill call, and now ends up
with more than they bargained for. Even after the issue is noticed,
resolving it requires reinventing some of the pgrep logic, which is
unfortunate.

This commit adds the -A/--ignore-ancestors option which excludes pgrep's
ancestors from the results:

    % sudo ./pkill -9 -Acf someelevatedcmdline
    0

We looks at multiple layers of the process hierarchy because, while
things like sudo only have one layer of shimming, some mechanisms (like
those found in a typical container manager like those found in Docker or
Kubernetes) may have many more.

Signed-off-by: Chris Down <chris@chrisdown.name>
2 years agobuild-sys: Fix paths for check-lib
Craig Small [Wed, 31 Aug 2022 07:30:34 +0000 (17:30 +1000)]
build-sys: Fix paths for check-lib

Forgot to move the location for test_Itemtables

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agoskill: Update include location too
Craig Small [Mon, 29 Aug 2022 11:37:40 +0000 (21:37 +1000)]
skill: Update include location too

skill got missed in the main update as its not compiled by
default.

2 years agodocs: Update manpages
Craig Small [Mon, 29 Aug 2022 10:56:43 +0000 (20:56 +1000)]
docs: Update manpages

Change include directory <procps/ -> <libproc2/
Change link instruction -lproc-2 -lproc2

2 years agobuild-sys: Move git-version-gen
Craig Small [Mon, 29 Aug 2022 10:53:01 +0000 (20:53 +1000)]
build-sys: Move git-version-gen

git-version-gen was the only file in misc/ moving it to local/

2 years agonls: Update translations for lib change
Craig Small [Mon, 29 Aug 2022 10:50:53 +0000 (20:50 +1000)]
nls: Update translations for lib change

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agomisc: Update pc file to new library name
Craig Small [Mon, 29 Aug 2022 10:42:45 +0000 (20:42 +1000)]
misc: Update pc file to new library name

2 years agotestsuite: Update the library tests for new location
Craig Small [Mon, 29 Aug 2022 10:40:45 +0000 (20:40 +1000)]
testsuite: Update the library tests for new location

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agolibrary: Rename to libproc2
Craig Small [Mon, 29 Aug 2022 10:38:17 +0000 (20:38 +1000)]
library: Rename to libproc2

The newlib library used to be called libproc-2 but the new
name is preferred.

References:
 https://www.freelists.org/post/procps/Next-for-newlib,3

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agobuild-sys: Relocate lib/
Craig Small [Mon, 29 Aug 2022 10:28:03 +0000 (20:28 +1000)]
build-sys: Relocate lib/

test files in lib go to src/tests
include/ goes to local/
lib/*.c goes to local/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agobuild-sys: Need to add libary includes
Craig Small [Mon, 29 Aug 2022 09:16:49 +0000 (19:16 +1000)]
build-sys: Need to add libary includes

The default path didn't add the library includes. A standard
build would work, but a make distcheck would not.

2 years agobuild-sys: Update tests to new binary locations
Craig Small [Mon, 29 Aug 2022 09:13:10 +0000 (19:13 +1000)]
build-sys: Update tests to new binary locations

2 years agobuild-sys: Relocate library to library/
Craig Small [Mon, 29 Aug 2022 09:02:44 +0000 (19:02 +1000)]
build-sys: Relocate library to library/

All the dependent programs needed to have their includes moved too

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agomisc: Move Documentation to doc
Craig Small [Mon, 29 Aug 2022 08:38:52 +0000 (18:38 +1000)]
misc: Move Documentation to doc

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agonls: Update translations to new source location
Craig Small [Mon, 29 Aug 2022 08:35:04 +0000 (18:35 +1000)]
nls: Update translations to new source location

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agonls: Minor translation update
Craig Small [Mon, 29 Aug 2022 08:30:50 +0000 (18:30 +1000)]
nls: Minor translation update

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agomisc: Move all binaries to src
Craig Small [Mon, 29 Aug 2022 08:29:28 +0000 (18:29 +1000)]
misc: Move all binaries to src

*.c -> src/
ps/* src/ps/
top/* src/top/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agobuild-sys: Rearrange the manual pages
Craig Small [Mon, 29 Aug 2022 08:07:43 +0000 (18:07 +1000)]
build-sys: Rearrange the manual pages

All man pages are found in ./man
man-po -> po-man

References:
 https://www.freelists.org/post/procps/Next-for-newlib,3

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agobuild-sys: Removal of contrib directory
Craig Small [Mon, 29 Aug 2022 07:46:03 +0000 (17:46 +1000)]
build-sys: Removal of contrib directory

There is nothing we have used here for over a decade

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotestsuite: Add test for fatal_proc_unmounted
Craig Small [Mon, 1 Aug 2022 12:23:38 +0000 (22:23 +1000)]
testsuite: Add test for fatal_proc_unmounted

Adding a check to ensure that fatal_proc_unmounted returns
values for things that do not just sit in /proc/self/stat

References:
 commit 52bd019d8ca09ecfec34b5020eb7b8d612c315f8

2 years agolibrary: refactor flawed function fatal_proc_unmounted
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
library: refactor flawed function fatal_proc_unmounted

This commit addresses a potentially disastrous flaw in
that fatal_proc_unmounted() function wherein requested
item(s) might not have been returned to the caller yet
were specified at the time of a 'new' or 'reset' call.

The root cause, uncovered by Craig, was due to the old
library look_up_our_self() support function which only
would populate a proc_t with limited 'stat' file data.

This routine will now act the same as all other <pids>
functions which return a stack or stacks. Whatever was
specified with a 'new' or 'reset' will be returned, if
the passed 'return_self' parameter is other than zero.

[ as is so often the case, when flawed code is fixed ]
[ former complexity can be reduced as a side benefit ]

Reference(s):
https://www.freelists.org/post/procps/issue-245-plus-one,2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: revert mention of limits for fatal_proc_unmounted
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
doc: revert mention of limits for fatal_proc_unmounted

With the next commit the fatal_proc_unmounted function
will be refactored to behave as it always should have.
So, a need for the user 'stat' caution will disappear.

Reference(s):
. original man page change
commit 7d44c94317941c1cd3d41325a0128010fe5d1331

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agops: adapted to change of VSIZE_PGS item to VSIZE_BYTES
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
ps: adapted to change of VSIZE_PGS item to VSIZE_BYTES

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: change misnamed VSIZE_PGS item to VSIZE_BYTES
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
library: change misnamed VSIZE_PGS item to VSIZE_BYTES

Gosh this particular flaw originated way back in 2015.

[ that was when we burdened a caller with additional ]
[ responsibilities for 'stacks_alloc', 'stacks_fill' ]
[ and 'stacks_dealloc'. damn implementation details. ]

Reference(s):
. Aug, 2015 - introduced<pids> api
commit 7e6a371d8a36b250a2edddff9f5d059640b8132e

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 agodoc: Mention fatal_proc_unmounted limitations
Craig Small [Wed, 27 Jul 2022 11:12:10 +0000 (21:12 +1000)]
doc: Mention fatal_proc_unmounted limitations

Discovered this while trying to port programs that use the deleted
libprocps function look_up_our_self() which can be found with the
fatal_proc_unmounted() function.

While procps_pids_new() will allow you to specify any items you
care to think of, a subsequent call to fatal_proc_unmounted()
will only fill in the values found in /proc/self/stat.

Added a caveat to the procps_pids manpage pointing out this
limitation.

References:
 https://salsa.debian.org/xorg-team/app/apitrace/-/blob/debian-unstable/lib/os/os_memory.hpp#L44
 https://gitlab.com/-/snippets/2377884

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotop: eliminate a potential abend when exiting 'A' mode
Jim Warner [Tue, 26 Jul 2022 05:00:00 +0000 (00:00 -0500)]
top: eliminate a potential abend when exiting 'A' mode

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 6aedeac667267b24ba7f03914eec768d661651ed
. Jun, 2018 - adressed edge case, new bugs created
commit 9d59ddc4661453dc65a8fc81dd75bfea40b7696c
. Sep, 2018 - additional edge case addressed
commit 59f02f19c796cdd83a9ec8751f83e10c42080a44
. May, 2021 - some abends fixed, new error created
commit 8281ac4f98cf04c51cbeb746d214201531d660ec
. Jun, 2021 - try to prorect against future errors
commit 2ea082b4af6f4751548e7583fe7430cd97935318
. Sep, 2021 - integrate mkVIZ & 'focused' tasks
commit 69978e365043f27305e487709474947bb377084d

Discovered by: Tyson Nottingham
Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: make the library API pages a little more readable
Jim Warner [Tue, 26 Jul 2022 05:00:00 +0000 (00:00 -0500)]
doc: make the library API pages a little more readable

Use of the the '.B' and '.BI' man documentation macros
had rendered the three library API pages less readable
than they could be. In addition, sometimes the pointer
indicator and an identifier were separated by a space.

So, this commit will trade those macros for some '.RI'
and '.RB' macros plus treat the pointers consistently.

[ plus we no longer italicize sort 'stacks' brackets ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agonls: Update po files
Craig Small [Mon, 18 Jul 2022 10:55:01 +0000 (20:55 +1000)]
nls: Update po files

Updates to cover the "new used" change and the pidwait change

2 years agopgrep: Better warning if pidfd_open not implemented
Craig Small [Mon, 18 Jul 2022 10:51:41 +0000 (20:51 +1000)]
pgrep: Better warning if pidfd_open not implemented

If procps is built on a Linux 5.3+ system then pidwait
is built with pidfd_open(). If that program is run on
a system < 5.3 then it gives an odd generic error.

If we get a ENOSYS from one pid, we will get it for all
the others so its better to explain what happens and terminate.

The man page is updated to note this issue.

This came up due to killall in psmisc using pidfd_send_signal

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
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 agops: Make STIME entries thread safe
Craig Small [Thu, 30 Jun 2022 11:15:37 +0000 (21:15 +1000)]
ps: Make STIME entries thread safe

Using localtime() can be a problem due to the static buffer for
the return value. It's simple enough to use localtime_r()

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotop: if line editing, account for invisible characters
Jim Warner [Tue, 28 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: if line editing, account for invisible characters

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
Jim Warner [Sun, 26 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: adjust the man page alignment for 'Ctrl' commands

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

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 agodoc: Note new Used behavour
Craig Small [Sat, 25 Jun 2022 01:42:08 +0000 (11:42 +1000)]
doc: Note new Used behavour

Added note to NEWS in the lbirary section
Updated free.1 as it specifies the calculation

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotop: adapt for modification to 'MEMINFO_MEM_USED' item
Jim Warner [Wed, 22 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: adapt for modification to 'MEMINFO_MEM_USED' item

With the library change calculating 'MEMINFO_MEM_USED'
top must be tweaked in order to retain the distinction
between non-cached used memory and cached used memory.

[ assuming one of the two graphs are being displayed ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: modify calculation of 'MEMINFO_MEM_USED' item
Jim Warner [Wed, 22 Jun 2022 05:00:00 +0000 (00:00 -0500)]
library: modify calculation of 'MEMINFO_MEM_USED' item

In an effort to more accurately reflect 'used' memory,
we will now rely on the kernel's estimate of available
memory. Thus, 'MEMINFO_MEM_USED' will be calculated as
just 'MEMINFO_MEM_TOTAL' less 'MEMINFO_MEM_AVAILABLE'.

Reference(s):
. thread leading to agreed upon change
https://www.freelists.org/post/procps/free-regression-due-to-a-different-calculation-of-Used-memory
. where consensus reached
https://www.freelists.org/post/procps/free-regression-due-to-a-different-calculation-of-Used-memory,11
https://www.freelists.org/post/procps/free-regression-due-to-a-different-calculation-of-Used-memory,12

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 agotop: adjust some parenthesis for correct '^N' behavior
Jim Warner [Thu, 16 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: adjust some parenthesis for correct '^N' behavior

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
Jim Warner [Thu, 16 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: make 'n/a' (not applicable) notation translatable

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>