]> granicus.if.org Git - procps-ng/log
procps-ng
2 years agotop: fix a flaw in excluding a string from translation
Jim Warner [Tue, 4 Oct 2022 05:00:00 +0000 (00:00 -0500)]
top: fix a flaw in excluding a string from translation

In that commit referenced below, I removed the command
line help text from any translation so the TP wouldn't
delay our 4.0.1 release any further. In looking to the
future, when we might be able to reverse that, I found
gettext tools blocking use of the compile conditional.

They are too primitive for the original approach so we
must modify that exclusion mechanism hack accordingly.

____________________________excerpted program comments

The provision excluding some strings is intended to be
used very sparingly. It exists in case we collide with
some translation project person in a position to delay
a future release over his or her personal preferences.

If it's ever enabled, it will produce a fatal compiler
error as our only option since those gettext tools are
far too primitive to be influenced with a conditional.
They always ignore a '_X()' macro no matter its state.

Reference(s):
commit 8a368bfb05a978a9904647f128dec8f1c4d4cc84

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agonls: man translation updates v4.0.1rc3
Craig Small [Tue, 4 Oct 2022 11:36:48 +0000 (22:36 +1100)]
nls: man translation updates

2 years agonls: Update translations
Craig Small [Tue, 4 Oct 2022 00:02:04 +0000 (11:02 +1100)]
nls: Update translations

2 years agotop: enable exclusion of some strings from translation
Jim Warner [Sat, 1 Oct 2022 05:00:00 +0000 (00:00 -0500)]
top: enable exclusion of some strings from translation

The provision excluding some strings is intended to be
used very sparingly. It exists in case we collide with
some translation project person in a position to delay
a future release over his or her personal preferences.

(it's currently used only on v4.0.1 command line help)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: always validate that p-core/e-core identification
Jim Warner [Sat, 1 Oct 2022 05:00:00 +0000 (00:00 -0500)]
top: always validate that p-core/e-core identification

Prior to this commit, when the '5' key was struck, top
would check for the presence of e-cores just one time.

That meant if a some cpu was brought online, and it in
turn exposed a new e-core after top has started, users
needed a top restart to activate the  new '5' feature.

So, now we'll check for any e-cores with each '5' key.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: tweak support of p-core/e-core identification
Jim Warner [Sat, 1 Oct 2022 05:00:00 +0000 (00:00 -0500)]
library: tweak support of p-core/e-core identification

Wow, after this we'll eliminate one 'jmp' instruction!

[ plus we can also save a single precious whitespace ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agonls: Update translations v4.0.1rc2
Craig Small [Thu, 29 Sep 2022 22:28:58 +0000 (08:28 +1000)]
nls: Update translations

2 years agoNEWS: Add entry for free --si fix
Craig Small [Wed, 28 Sep 2022 07:59:23 +0000 (17:59 +1000)]
NEWS: Add entry for free --si fix

References:
 procps-ng/procps!163

2 years agofree: --si changes base of default output
Jan Rybar [Wed, 28 Sep 2022 07:57:03 +0000 (07:57 +0000)]
free: --si changes base of default output

2 years agobuild-sys: Allow enable-watch9bit and with-ncurses
Craig Small [Wed, 28 Sep 2022 07:42:17 +0000 (17:42 +1000)]
build-sys: Allow enable-watch9bit and with-ncurses

The commit that changed configure.ac was supposed to check for when
someone removes ncurses using the flag --without-ncurses

Unfortunately the change didn't check if the user was specifying
--without or --with meaning if they didn use --with-ncurses the
configure script would error out.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
References:
  commit 812864181408398af98b217f384205a6f2f9cb68
  procps-ng/procps#251

2 years agodoc: updated with library p-core/e-core identification
Jim Warner [Wed, 28 Sep 2022 05:00:00 +0000 (00:00 -0500)]
doc: updated with library p-core/e-core identification

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: exploit that library p-core/e-core identification
Jim Warner [Wed, 28 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: exploit that library p-core/e-core identification

I sure hope we won't disappoint the library with these
changes since we're only exploiting one of the two new
enumerators that the immediately prior patch provided.

Now top will be able to offer a visual clue as to each
cpu (thread actually) core association. Is it a P-core
offering multiple threads or a single threaded E-core.

We'll accomplish this feat with a subtle change to the
states portion ('t' toggle) of the summary area. Where
before processors were represented as 'Cpu', they will
now be displayed as 'CpP' (P-core) and 'CpE' (E-core).

[ assuming that new '5' command toggle has been used ]

There are also new provisions for filtering those cpus
by their core type association via the new '5' toggle.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: provided for cpu p-core/e-core identification
Jim Warner [Wed, 28 Sep 2022 05:00:00 +0000 (00:00 -0500)]
library: provided for cpu p-core/e-core identification

With Intel's 12th generation Alder Lake processors now
providing two distinct types of core, it would be nice
if the library offered some sort of clue to core type.

Well, with this patch it does. We'll have 2 additional
enumerators. One deals with the cpu's core association
and the other provides the type of that core (P or E).

[ now, all we need is for some program to exploit it ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: avoid any potential race involving 'BREAK_screen'
Jim Warner [Sun, 18 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: avoid any potential race involving 'BREAK_screen'

When that 'Bottom' window was being finalized, an enum
of BREAK_screen was added to the Frames_signal values.
This was done so some full screen replacement function
could flag the need for that bottom window to go away.

Around that same time, top was made more responsive to
keyboard input so that residual portions of a previous
bottom window would not linger until the next refresh.
This happened if going from a larger (^N, environment)
bottom window to some smaller window (^P, namespaces).

The combined effect of these changes was to create the
potential race condition this commit addresses. If the
user encountered a SIGWINCH while on any of those full
screen replacement displays (help, fields mgmt, etc.),
endless redraws would occur. A ^C was the only option.

Henceforth we will protect against any redraw loops by
clearing Frames_signal each time a redraw is required.

[ along the way, we'll make the 'q' key work on that ]
t secondary 'windows' help screen as it should, even ]
[ though it is not documented on that screen itself. ]

Reference(s):
. May, 2022 - more responsive to keyboard input
commit 3ea1bc779fb7ca5bf065a5ca620ec5b5823bc61c
. May, 2022 - maybe force the bottom window off
commit d66c1f39b52d53ec279fc638aa4a6352d7672201

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: try avoiding the edge of a 'divide by zero' cliff
Jim Warner [Sun, 18 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: try avoiding the edge of a 'divide by zero' cliff

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 5c5bff392bfaf78b7bacb9b954c1fd1e9d818544
. true source of my original sin
commit 2d5b51d1a2aa19d077a2f3db5be187f982d70e70

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: fix 'TOG4_MEM_1UP' if two abreast summary display
Jim Warner [Sun, 18 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: fix 'TOG4_MEM_1UP' if two abreast summary display

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
Jim Warner [Sun, 18 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: enhance memory graphs two abreast summary display

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
Jim Warner [Sun, 18 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: cosmetic changes with two abreast summary display

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
Jim Warner [Sun, 18 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: distinct separator if two abreast summary display

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
Jim Warner [Sun, 18 Sep 2022 05:00:00 +0000 (00:00 -0500)]
top: harden detailed stats two abreast summary display

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
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 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 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
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
Jim Warner [Tue, 14 Jun 2022 05:00:00 +0000 (00:00 -0500)]
NEWS: acknowledge that utf8 multi-byte character input

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

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
Jim Warner [Mon, 13 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: provide for visual hint when overtype mode active

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
Jim Warner [Mon, 13 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: avoid premature forced loss of that bottom window

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 d66c1f39b52d53ec279fc638aa4a6352d7672201

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

[ 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
Jim Warner [Thu, 2 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: provides a new user 'message log' display ability

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 agolibrary: at unref, close these cached file descriptors
Jim Warner [Thu, 2 Jun 2022 05:00:00 +0000 (00:00 -0500)]
library: at unref, close these cached file descriptors

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: Close filehandle for procps_loadavg
Craig Small [Thu, 2 Jun 2022 06:36:40 +0000 (16:36 +1000)]
library: Close filehandle for procps_loadavg

Previous commit didn't close the filehandle after making the
open non-persistent.

References:
 commit 8fcd14de18b998647ba47f5b35feb1d85e2d2f08

2 years agolibrary: clear rc in procps_loadavg again
Craig Small [Tue, 31 May 2022 12:03:22 +0000 (22:03 +1000)]
library: clear rc in procps_loadavg again

During the changes to procps_loadavg I didn't set the initial
value for retval, meaning it was a random number.
It is now correctly intialised to zero.

References:
  commit 8fcd14de18b998647ba47f5b35feb1d85e2d2f08

2 years agotload: Report on lack of /proc/loadavg
Craig Small [Tue, 31 May 2022 11:35:40 +0000 (21:35 +1000)]
tload: Report on lack of /proc/loadavg

Now that the library correctly returns an error if loadavg
is not available, tload can tell the user the bad news.

References:
 procps-ng/procps#227
 commit 8fcd14de18b998647ba47f5b35feb1d85e2d2f08

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agolibrary: Return -errno not print messages
Craig Small [Tue, 31 May 2022 11:32:03 +0000 (21:32 +1000)]
library: Return -errno not print messages

A library should generally return an error value, rather than
printing to stderr a message. procps_loadavg() had a few things
to change:

It had a global buffer, but we don't call this function over and
over except in tload. It also did had two macros where a plain
fopen() would do the job nicely.

This removed the macro FILE_TO_BUF which was used everywhere in oldlib
but only for loadavg in newlib.

This library change will set us up to fix tload.

2 years agofree: better error message if meminfo not available
Craig Small [Tue, 31 May 2022 11:10:18 +0000 (21:10 +1000)]
free: better error message if meminfo not available

When /proc is mounted with subset=pid free just gives the
standard cannot create meminfo structure without any hint why.
free now checks the return value and if it is -ENOENT then it
gives more information about the problem.

References:
 procps-ng/procps#227

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agolibrary: Cygwin doesnt have /proc/vmstat
Craig Small [Tue, 31 May 2022 10:41:30 +0000 (20:41 +1000)]
library: Cygwin doesnt have /proc/vmstat

Make the vmstat_read_failed() return non-error for Cygwin as
it always will error because /proc/vmstat doesn't exist.

Patch from Achim of the Cygwin project.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotop: the bottom 'window' headings are now translatable
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
top: the bottom 'window' headings are now translatable

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: remove the 'BOT_MENU_YES' prototype demonstration
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
top: remove the 'BOT_MENU_YES' prototype demonstration

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
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
top: don't make translatable text subject to a #define

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
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
top: cleanup of miscellaneous stuff from prior commits

Fix some errors introduced in the commits shown below.

Reference(s):
. Apr, 2022 - 'keys_global' missed redundancy
commit 27f5904edd3772a2f3f66ac62148dee636295933
. Apr, 2022 - added extraneous comma in help text
commit fb32021eeb6f78f01bf455231423a162c9766408

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: Cygwin only has 4 cpu numbers
Craig Small [Thu, 26 May 2022 07:53:43 +0000 (17:53 +1000)]
library: Cygwin only has 4 cpu numbers

Old library never checked how many matches there were meaning that
both 8-number and 4-number cpu lines would work.

2 years agotop: enable bottom 'window' multi-byte char capability
Jim Warner [Wed, 25 May 2022 05:00:00 +0000 (00:00 -0500)]
top: enable bottom 'window' multi-byte char capability

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
Jim Warner [Wed, 25 May 2022 05:00:00 +0000 (00:00 -0500)]
top: rework bottom 'window' logic to reduce redundancy

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 agobuild-sys: Give sensible errors if missing pkg-config
Craig Small [Wed, 25 May 2022 11:08:50 +0000 (21:08 +1000)]
build-sys: Give sensible errors if missing pkg-config

pkg-config is used to find various libraries used by procps.
Unfortunately it, or rather automake, give terrible misleading
error messages if pkg-config is not installed.

At ./configure time you get this:
configure: error: ncurses support missing/incomplete (for partial
build use --without-ncurses)

At automake time you get this:
configure.ac:33: error: possibly undefined macro: AC_MSG_ERROR
      If this token and others are legitimate, please use m4_pattern_allow.
      See the Autoconf documentation.
configure.ac:48: error: possibly undefined macro: AS_IF
configure.ac:113: error: possibly undefined macro: AC_DEFINE

The internet is filled with such wonderful other examples.

This commit does two things:
 At autoconf time, check PKG_PREREQ macro is defined which is found in
pkg.m4 and tells us pkg-config has its macros available.
 At configure time, check the result of the pkg-config test and error
 if it didn't find it.

Now it actually says its missing pkg-config. To be fair, the autoconf
check is "documented" and recommended in pkg.m4 file.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agobuild-sys: Use ncursesw by default
Craig Small [Sat, 21 May 2022 01:06:57 +0000 (11:06 +1000)]
build-sys: Use ncursesw by default

The existing build system would only require wide ncurses for
a wide watch and even if the library was there would not link
anything else to it.

The first issue which #123 made me think of, is if ncursesw
was there and ncurses is not, why not use ncursesw?

A more major issue is if programs such as slabtop are linked
to ncurses, then certain languages will display their text
wrong, as found in #237.

The days of assuming ASCII only is ok are over the build system
now does the following:
 1. If ncursesw is available use this for all relevant programs
 2. If ncursesw is not but ncurses is, use this instead
 3. If you enable 8bit watch and either disable ncurses or
    we cannot find ncursesw error at configure time.

In related news, I hate M4sh.

References:
 procps-ng/procps#123
 procps-ng/procps#237

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agolibrary: silence the clang warning for 'uptime' module
Jim Warner [Wed, 18 May 2022 05:00:00 +0000 (00:00 -0500)]
library: silence the clang warning for 'uptime' module

Reference(s):
proc/uptime.c:191:9: warning: variable 'uphours' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

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

Really, extend shift+tab navigation to only 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>