]> granicus.if.org Git - procps-ng/log
procps-ng
3 years agotop: utilize getopt and introduce long cmdline options
Jim Warner [Sat, 4 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: utilize getopt and introduce long cmdline options

For quite some time now, top has stood out like a sore
thumb regarding the approach to cmdline options & help
text.  Only short options were used and that same help
text was displayed for '-h' (help) plus 'v' (version).

[ also, top 'rolled his own' when it came to parsing ]
[ options while avoiding that getopt implementation. ]

Well, with this commit all of that has changed and top
now has added a long form of his options. Additionally
he employs getopt_long() for the bulk of that parsing.

[ however, top will still avoid separate fputs calls ]
[ characteristic of other procps-ng programs when it ]
[ comes to help. rather all such text is one string. ]

Along the way, the following major getopt deficiencies
were addressed, assuming the absence of a new #define:

* an equals sign ('=') is allowed on both option forms

* whitespace is allowed before & after the equals sign

* optional arguments needn't abut their related option
for short form nor is an '=' required with either form

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: some minor organizational tweaks for man document
Jim Warner [Fri, 3 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: some minor organizational tweaks for man document

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: trade 2 strstr & atoi calls for 1 sscanf call
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: trade 2 strstr & atoi calls for 1 sscanf call

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: just eliminate a couple of unnecessary braces
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: just eliminate a couple of unnecessary braces

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: and just eliminate a couple of unnecessary braces
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: and just eliminate a couple of unnecessary braces

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: reposition call to cpus_refresh() for consistency
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: reposition call to cpus_refresh() for consistency

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: corrected single man document typographical error
Jim Warner [Sun, 22 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: corrected single man document typographical error

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: man page now reflects change for the 'select' i/f
Jim Warner [Thu, 12 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: man page now reflects change for the 'select' i/f

Reference(s):
https://www.freelists.org/post/procps/important-extension-to-newlib,4
. 'select' i/f top response
commit 23776571a74ce9c526b0171ca8ba7ec0357d8002
. 'select' i/f library change
commit af34cc964ae7667db15d2507f24098c26ba3c664

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: address major bug in the 'listed_nextpid' guy
Jim Warner [Tue, 10 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: address major bug in the 'listed_nextpid' guy

Ever since 2003, the 'listed_nextpid' routine has been
misrepresenting its duties. Far from finding processes
in a list given to openproc, it just inserted the next
pid in that list into the passed proc_t as BOTH a tgid
and tid. There was no attempt to validate such values.

The net result is that tid & tgid were valid only with
a thread group leader. When called with a pid for some
sibling thread, the resulting tgid would be incorrect.

With this commit, our little function will now attempt
to validate both the tid and tgid. If this should fail
then the fallback position will be the same as what we
inherited. So we're no worse off & likely much better.

[ note that calling the function with a thread's pid ]
[ likely stems from 2011 when a 'readeither' routine ]
[ was added which dealt with both tasks and threads! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: disabled some code that now serves no purpose
Jim Warner [Tue, 10 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: disabled some code that now serves no purpose

In the patch shown below, two lines involving the flag
PROC_UID were uncommented (enabled). However given the
construct of the readeither function, it is impossible
for the simple_readtask guy to be called when its TGID
leader has already been ignored. So, let's disable it.

[ it's only now true that the lines serve no purpose ]
[ after the commit shown below tweaked readeither to ]
[ access the base directory of the tgid leader. but, ]
[ before that, the 2 lines should have been enabled! ]

Reference(s):
. two lines uncommented
commit af34cc964ae7667db15d2507f24098c26ba3c664
. tweaked readeither
commit a37526260917bac624ae6b75fd9f4ea7287d81ad

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: thread mode transitions should remove focus ('F')
Jim Warner [Sun, 8 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: thread mode transitions should remove focus ('F')

The commit referenced below forced a return to row one
whenever there was a thread mode transition. Now, with
our new focus ('F') feature, we should adopt a similar
philosophy so as to avoid potential display anomalies.

Reference(s)
. Jun 2018, force row 1 w/ thread mode transition
commit 19ec80bd416c570a70f2fa7fa7e84a2667d71a08

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: respond to that preceding fix in the 'select' i/f
Jim Warner [Sat, 7 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: respond to that preceding fix in the 'select' i/f

This patch makes it possible to honor our '-H' threads
switch even when operating under that '-p' switch used
to select/filter only certain pids. Of course, what we
have done is just exploit the new library enhancement.

[ and we're pretending we don't know the enumerators ]
[ PIDS_FETCH_THREADS_TOO + PIDS_SELECT_PID are equal ]
[ to that PIDS_SELECT_PID_THREADS enumerator itself. ]

[ thankfully, those dependencies can be assured with ]
[ a 'make check-lib' which exploits ITEMTABLE_DEBUG! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: repair <pids> api boo-boo in the 'select' i/f
Jim Warner [Sat, 7 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: repair <pids> api boo-boo in the 'select' i/f

The patch referenced below corrected some flaws in the
procps_pids_select implementation. But, there remained
one flaw which this commit will now hopefully address.

Rather than assume callers wished to select only tasks
and not threads meant a command like 'top -H -p 10329'
works differently under newlib than release 3.3.17. It
fails to honor the '-H' (threads) switch under newlib.

So, to fix that oops, we'll allow that select function
to get threads or tasks depending on its 'which' parm.

Reference(s):
. Oct 2015, some flaws corrected
commit bc616b361596bc3008800de839b88446508cfdd0

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: ensure thread group leader retrieval accuracy
Jim Warner [Sat, 7 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: ensure thread group leader retrieval accuracy

With that recent addition of the autogroup provisions,
it became apparent that '/proc/<pid>/task' information
is sometimes incomplete. In fact, there's no autogroup
file at all in any '/proc/<pid>/task/<pid>' directory!

As a result, when the top -H mode was invoked, all the
processes showed a -1 for AGID, even the group leader.

So, this commit will ensure that for every TGID leader
its basic '/proc/<pid>' directory will always be used.
The 'task' subdirectory is now only used for siblings.

[ and it's time that readeither prologue was updated ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: announce changes for displaying autogroup values
Jim Warner [Fri, 6 Aug 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: announce changes for displaying autogroup values

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: document new items for displaying autogroup values
Jim Warner [Fri, 6 Aug 2021 05:00:00 +0000 (00:00 -0500)]
ps: document new items for displaying autogroup values

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: added 2 new fields for displaying autogroup values
Jim Warner [Fri, 6 Aug 2021 05:00:00 +0000 (00:00 -0500)]
ps: added 2 new fields for displaying autogroup values

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: document 2 fields for displaying autogroup values
Jim Warner [Thu, 5 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: document 2 fields for displaying autogroup values

[ we'll also eliminate a couple of references to the ]
[ repurposed 'F' command which should have gone away ]
[ with the introduction of that new 'focus' feature! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: exploit new items for displaying autogroup values
Jim Warner [Thu, 5 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: exploit new items for displaying autogroup values

Ordinarily, whenever a new field is added to top, that
RCF_VERSION_ID should be bumped which then prevents an
older version of top from reading the expanded rcfile.

With this change, however, we'll keep the existing 'k'
version since we've yet to release the newlib version.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: add provision for displaying autogroup values
Jim Warner [Thu, 5 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: add provision for displaying autogroup values

In the link referenced below there's an explanation of
the linux autogroup feature which has been around ever
since linux-2.6.38. With that explanation there's also
surprising (maybe shocking) revelations about the nice
and renice commands if CONFIG_SCHED_AUTOGROUP was set.

When autogroups are active, such programs are rendered
mostly useless because the nice value will only affect
scheduling priority relative to other processes in the
same autogroup. In order to accomplish what we thought
of as renice, that nice value in /proc/<pid>/autogroup
must be changed. Altering any single member of a group
will also affect every other member of that autogroup.

So, this commit will set the stage for users of newlib
to display autogroup identifiers plus their associated
nice values (now that their importance is understood).

Reference(s):
https://github.com/nlburgin/reallynice

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: eliminated an overlooked obsoleted <pids> API item
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
ps: eliminated an overlooked obsoleted <pids> API item

When several obsolete linux-2.6 fields were eliminated
and ps responded in the commit referenced below, there
was one reference overlooked. So, with this commit the
reference to PIDS_ALARM has been whacked at long last.

Reference(s):
. Sep 2016, ps response to removal
commit 86992bb58f59d617ee2bf20de4f2a185bf817dae

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: eliminate all field numbers from the man document
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: eliminate all field numbers from the man document

As far back as release 3.2.8 (maybe even farther) this
man page used a number with each field's descriptions.

That practice caused no real harm when top was limited
to a grand total of 26 fields (thru lower case letters
of the alphabet). However, now we've reached 70 fields
and, depending on the name that's chosen, adding a new
field could result in a massive renumbering of fields.

Thus, this patch eliminates such potential by removing
all numbers from section '3a. DESCRIPTIONS of Fields'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: refactor all the readproc.h 'PROC_FILL' flags
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
library: refactor all the readproc.h 'PROC_FILL' flags

The 'PROC_FILL' flags, found in readproc.h, had become
almost unmanageable. The hex values were scattered all
over the map as new flags had been introduced. So this
commit resets all of them and will help ensure any new
flags don't duplicate some already existing hex value.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: document summary area changes involving 2 abreast
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: document summary area changes involving 2 abreast

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: allow the summary memory lines to print 2 abreast
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: allow the summary memory lines to print 2 abreast

The commit shown below introduced two abreast printing
for %Cpu statistics. But, the Memory & Swap lines have
always been printed on separate lines when '4' was on.

With this commit, those lines will now be treated just
like %Cpu stats, either separate lines or two abreast.

Reference(s):
. May 2020, added '4' toggle for 2 abreast
commit 59f5a37a247184b3009af963706ca68198067185

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: add a visual separator to lines printed 2 abreast
Jim Warner [Wed, 4 Aug 2021 05:00:00 +0000 (00:00 -0500)]
top: add a visual separator to lines printed 2 abreast

When the '4' toggle is on, and Summary Area %Cpu lines
are shown two abreast, it's not always clear where the
separation is between the two processors. So with this
patch we'll now print a vertical bar separator between
them (looking similar to the existing field headings).

We will also reduce that 'GRAPH_suffix' constant to 1,
reflecting the the trailing ']' bracket only, so as to
maximize top's exploitation of available screen width.

[ plus a superfluous double '+ +' has now been fixed ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: TREE_FOCUS_X works properly with multiple windows
Jim Warner [Wed, 28 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: TREE_FOCUS_X works properly with multiple windows

As promised, this commit will ensure that TREE_FOCUS_X
impacts only the window under which an 'F' was issued.

Previously, when 'F' was invoked it would impact every
window that was displaying forest view. Now, only that
window where 'F' was applied will show the indentation
losses whenever multiple windows were being displayed.

[ each of the 4 windows can now have different focus ]
[ pids active and not impact any other forest views! ]

Reference(s):
. 'TREE_FOCUS_X' introduction
commit c23d2708d4a6a80e029289d630c84824d27b1ada

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: trade most pids_stack pointers for a WIN_t ppt ix
Jim Warner [Tue, 27 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: trade most pids_stack pointers for a WIN_t ppt ix

For every function whose parameters consist of a WIN_t
pointer and a pointer to a pids_stack, we will instead
pass the WIN_t pointer and index to that window's ppt.

This change will save six instructions per invocation,
and converts the index once in those called functions.

[ you can consider this an efficiency change, but it ]
[ is really being implemented so that 'TREE_FOCUS_X' ]
[ #define can be made to behave as one should expect ]
[ when running under top's 'alternate display' mode! ]

[ stay tuned for the very next commit to be pushed!! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: restored a function prologue lost a long time ago
Jim Warner [Mon, 26 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: restored a function prologue lost a long time ago

For some reason, when top was modified to exploit that
<pids> api, one function prologue was removed. So this
commit just restores it to the 'window_show' function.

Reference(s):
. Aug, 2015 - adapted to new <pids> api
commit 77dc22b9101af39fc30306e36d65cad2b396cc9e

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: new #define added for focus ('F') toggle tweaking
Jim Warner [Sun, 25 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: new #define added for focus ('F') toggle tweaking

Just to see if I could, the new #define will force the
indentation of a parent task to be reset to zero while
maintaining the proper child indentation relationship.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: introduced new focus toggle ('F'), man doc & NEWS
Jim Warner [Sat, 24 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: introduced new focus toggle ('F'), man doc & NEWS

[ i also corrected an unrelated typographical error! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: introduced new focus toggle ('F'), program source
Jim Warner [Sat, 24 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: introduced new focus toggle ('F'), program source

Sometimes, it might be useful to isolate a parent task
and its forked children from other system activity. As
an example, a user might want to examine workload in a
specific lxc container. Or maybe there is some need to
question what's happening under the same tmux session.

Since forest view mode tends to be a relatively stable
display, it will sometimes satisfy the above need. But
that mode can't currently guarantee the target process
always remains as the topmost task or even is visible.

So, this patch will enable focusing on any parent task
and keeping it as the topmost process while displaying
it and its forked children only. It then appears as if
there is no other activity in that system by virtue of
the blank lines which follow that final child process.

To implement this new feature, top's redundant 'F' key
has been repurposed. It made little sense devoting two
keys to the Fields Management screen (especially since
the key we've taken required two separate keystrokes).

[ and while we're at it, i also added punctuation to ]
[ the prologue for that renamed 'forest_display' guy ]
[ since all other forest functions used punctuation. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: make eu_TREE_LVL a signed int not an unsigned int
Jim Warner [Fri, 23 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: make eu_TREE_LVL a signed int not an unsigned int

Since the internally kept nesting 'level' under forest
view is limited to a maximum of 101, we will now treat
it as signed to avoid any potential conversion issues.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: standardize 'pointer-to-thing' whitespace use
Jim Warner [Thu, 22 Jul 2021 05:00:00 +0000 (00:00 -0500)]
library: standardize 'pointer-to-thing' whitespace use

When declaring a pointer there's usually a space after
the thing-pointed-to and no space between the asterisk
and the pointer-thingy itself. So this commit enforces
such conventions where needed on old library elements.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: whack a label & branch in 'summary_show' function
Jim Warner [Wed, 21 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: whack a label & branch in 'summary_show' function

If there are zero numa nodes then the View_CPUNOD flag
cannot possibly be set. So it was unnecessary to check
both the numa total and View_CPUNOD in 'summary_show'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: added a new #define to test absence of numa nodes
Jim Warner [Tue, 20 Jul 2021 05:00:00 +0000 (00:00 -0500)]
top: added a new #define to test absence of numa nodes

This new #define will produce top results identical to
the results achieved for './configure --disable-numa'.

However it keeps the change entirely local to our top.

[ it has been introduced to test the following patch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: just play catch up with some top implementations
Jim Warner [Mon, 19 Jul 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: just play catch up with some top implementations

These changes were already implemented for this newlib
version, but not in the the master branch top version.

[ and we also add the missing 3.3.17 ps 'exe' change ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotestsuite: Add test for previous sysctl change
Craig Small [Tue, 20 Jul 2021 12:45:17 +0000 (22:45 +1000)]
testsuite: Add test for previous sysctl change

Add a check for path traversal to sysctl.

References:
 commit f25d462166f80b844d33dad3e4c06088c809a426

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agosysctl: Check path is under /proc/sys
Craig Small [Tue, 20 Jul 2021 12:36:15 +0000 (22:36 +1000)]
sysctl: Check path is under /proc/sys

sysctl would try to read/write any path you gave it either on
the command line or configuration file. It would append /proc/sys
on the path but not check for any sneaky path traversal with ../

This commit means it first resolves all paths using realpath(3)
and then checks the path starts with "/proc/sys/"

At first I thought this might be a non-issue, but perhaps someone
could put a file into the sysctl configuration path and.. do
something? Anyway its a 8-line fix and makes things more correct.

References:
 #179

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agodoc: updated NEWS plus top(1) for IO accounting fields
Jim Warner [Tue, 22 Jun 2021 05:00:00 +0000 (00:00 -0500)]
doc: updated NEWS plus top(1) for IO accounting fields

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: fix a fix for the 'bye_bye' function (merge #127)
Jim Warner [Mon, 21 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: fix a fix for the 'bye_bye' function (merge #127)

In the merge request shown below, 1 too many bytes are
written to stdout thus including the terminating null.
As the cure, this commit just reduces the length by 1.

[ along the way, we will remove some unneeded braces ]
[ plus add some additional comments with attribution ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/127
. original ported cchange
commit 6b8980a3b6279058d727377e914cfb6439d6f178

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: documented those newly added IO accounting fields
Jim Warner [Sun, 20 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: documented those newly added IO accounting fields

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: follow ps lead & add several IO accounting fields
Jim Warner [Sun, 20 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: follow ps lead & add several IO accounting fields

Some time ago, IO accounting was added for the library
and exploited by the ps program. This patch just plays
a little catch-up & adds similar functionality to top.

[ and we also finally get around to incrementing the ]
[ rcfile id which should have already been done when ]
[ the smaps fields were added or, at least, with USS ]

Reference(s):
. added IO accounting to ps program
commit 8baf8eeab4d5cf4ce712f3a0048985fe045c87f7
. added IO accounting to library
commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: correct sources for IO accounting, <pids> api
Jim Warner [Sun, 20 Jun 2021 05:00:00 +0000 (00:00 -0500)]
library: correct sources for IO accounting, <pids> api

This patch just brings 'PIDS_IO' source into alignment
with the names being used in that /proc/<pid>/io file.

[ i had my chance to fix them in a whitespace change ]
[ made in the patch referenced below, but i blew it! ]

Reference(s):
commit 2dcbe71f3b8e3586acab0221b2e4c55d10cf8f76

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNLS: Update translate files
Craig Small [Thu, 17 Jun 2021 06:45:07 +0000 (16:45 +1000)]
NLS: Update translate files

3 years agotop: exploit the newly added library smaps_rollup item
Jim Warner [Wed, 16 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: exploit the newly added library smaps_rollup item

We're just following the ps program's lead introducing
a new 'USS' field to represent the non-swapped portion
of physical memory ('RSS') not shared by another task.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: adapt to the newly added library smaps_rollup item
Jim Warner [Wed, 16 Jun 2021 05:00:00 +0000 (00:00 -0500)]
ps: adapt to the newly added library smaps_rollup item

In that commit referenced below, a new field was added
to the ps program which required adding 2 newlib items
together. Such a need is now satisfied by the library.

So, this commit will just adapt ps for that provision.

Reference(s):
commit e782b1d85989a9d27474264d4d65ffe1c485bdc9

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: add new derived smaps_rollup item, <pids> api
Jim Warner [Wed, 16 Jun 2021 05:00:00 +0000 (00:00 -0500)]
library: add new derived smaps_rollup item, <pids> api

That recent addition of USS to the ps program prompted
this change.  Rather than have it (and soon top) add 2
separate items to yield the desired value, we will let
our new library perform the arithmetic when necessary.

Outside of a little extra storage, there is no runtime
costs for such an extension. There is, however, a real
benefit to having such code in the library. Now should
callers choose to sort on this new field, results will
be guaranteed to be what was expected (i.e. accurate).

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: refactor 'mkVIZ' support to avoid future problems
Jim Warner [Tue, 15 Jun 2021 05:00:00 +0000 (00:00 -0500)]
top: refactor 'mkVIZ' support to avoid future problems

In the patch referenced below, 2 potential abends were
fixed both of which involved 'alternate display mode'.

The root cause of those abends was a negative value in
the 'begnext' field for other than the current window.

And while that potential is fixed for now the existing
code almost invites such problems again in the future.

So, this patch will remove any temptation to name some
other window in the 'mkVIZrow1' macro. And, since that
macro is not the only source of 'begnext' changes, the
'mkVizrowX' is being added to identify such occasions.

[ and for symmetry i've added a 'mkVIZyes' macro and ]
[ ameliorated an otherwise surreptitious assignment! ]

Reference(s):
commit 8281ac4f98cf04c51cbeb746d214201531d660ec

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: Add PSS and USS fields
Craig Small [Wed, 16 Jun 2021 11:13:52 +0000 (21:13 +1000)]
ps: Add PSS and USS fields

The library added smaps_rollup fields in the referenced commit.
This commit exploits the new fields to give pss and uss options.

These options were first proposed back in 2015 by Petr Malat
and, with the library update, they are finally made it into ps.

Why use proportional or unique segment size? It is argued that
these give a better idea of the "real" memory usage of a process.

References:
 commit 12543b6c7690c379abc28e278cd804c05490a8b1
 issue #112
 https://www.freelists.org/post/procps/PSS-and-USS-support-for-ps
 https://lwn.net/Articles/230975/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotestsuite: Add test for free committed
Craig Small [Wed, 16 Jun 2021 10:34:33 +0000 (20:34 +1000)]
testsuite: Add test for free committed

Add a check for free -v for committed memory.

References:
 commit 16734d580eb779654e626f3b41a98992fc0d557d

3 years agofree: option to show memory commit limits
Craig Small [Wed, 16 Jun 2021 10:29:03 +0000 (20:29 +1000)]
free: option to show memory commit limits

This commit is largely the userland only changes found in !73
added by Jens Låås (@jelaas)

References:
 procps-ng/procps!73

3 years agoc: print strerror() instead of error code.
Érico Nogueira [Fri, 4 Jun 2021 16:10:28 +0000 (13:10 -0300)]
c: print strerror() instead of error code.

This changes error() behavior to match what glibc already does.

3 years agofree: Clean up scale_size and fix `free -h --si`
Jan Alexander Steffens (heftig) [Tue, 15 Jun 2021 18:43:36 +0000 (20:43 +0200)]
free: Clean up scale_size and fix `free -h --si`

- Simplify control flow a bit. We don't need two loop variables, either.
- Consistently use %lld for bytes.
- Fix the base handling for human-readable output. The code used to
  calculate *mebibytes* first, then scale that to the required exponent
  with the selected base, which is patently wrong.

Fixes https://gitlab.com/procps-ng/procps/-/issues/133

3 years agotop: fix two potential 'alternate display mode' abends
Jim Warner [Mon, 31 May 2021 05:00:00 +0000 (00:00 -0500)]
top: fix two potential 'alternate display mode' abends

This commit will address potential abends upon leaving
the windows help or color mapping screens and invoking
alternate display mode ('A').  It only happens if that
current window was changed with multiple 'a'/'w' keys.

So now, rather than leaving a trail of negative values
in the 'begtask' field, compliments of that win_select
function, we'll remove the mkVIZrow1 macro. Henceforth
it will be issued just once per user interaction. Thus
a promise of 'Curwin' only being impacted is restored.

[ my thanks to Vladimir Chren for reporting this bug ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/210
https://gitlab.com/procps-ng/procps/-/merge_requests/135

Discovered by:Vladimir Chren <vladimir.chren@gmail.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agosysctl man page update for pattern
Bas van der Vlies [Thu, 25 Feb 2021 08:35:33 +0000 (09:35 +0100)]
sysctl  man page update for pattern

pattern must be used before `--system` else it does not work for sysctl
file(s)

```
root# /sbin/sysctl --system --pattern '^net.ipv6'
* Applying /etc/sysctl.d/30-ceph-osd.conf ...
fs.aio-max-nr = 1048576
kernel.pid_max = 4194304
* Applying /etc/sysctl.d/protect-links.conf ...
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
* Applying /etc/sysctl.d/sara_tweaks.conf ...
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 0
* Applying /etc/sysctl.conf ...
```

vs:
```
root# /sbin/sysctl --pattern '^net.ipv6' --system
* Applying /etc/sysctl.d/30-ceph-osd.conf ...
* Applying /etc/sysctl.d/protect-links.conf ...
* Applying /etc/sysctl.d/sara_tweaks.conf ...
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 0
* Applying /etc/sysctl.conf ...
```

References:
 !124

3 years agoconfigure: add macro to check for __PROGNAME
Henrik Grimler [Wed, 26 May 2021 13:45:02 +0000 (15:45 +0200)]
configure: add macro to check for __PROGNAME

in include/c.h we check if HAVE___PROGNAME is defined, but the
corresponding macro for setting (or not setting) it is missing from
the configure script. This commit adds the missing macro, by
copying it from the macro in tmux.

3 years agoCoverity scan findings - memleaks, unused vars, potential nullptr dereferences
Jan Rybar [Thu, 6 May 2021 14:30:54 +0000 (16:30 +0200)]
Coverity scan findings - memleaks, unused vars, potential nullptr dereferences

3 years agolibrary: rename/reposition two enumerators, <pids> api
Jim Warner [Fri, 30 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: rename/reposition two enumerators, <pids> api

The two special hugetlbfs items were misnamed. The TBL
reference (table) should be TLB (transaction lookaside
buffer). Besides, I never liked their position anyway!

[ and one macro argument tweak is being snuck in too ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: add comments for the new smaps_rollup provisions
Jim Warner [Wed, 28 Apr 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: add comments for the new smaps_rollup provisions

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: document all of top's new smaps_rollup provisions
Jim Warner [Tue, 27 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: document all of top's new smaps_rollup provisions

[ of course, we had to renumber most existing fields ]
[ with these additions. plus, some typos were fixed. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: exploit some of those new smaps_rollup provisions
Jim Warner [Tue, 27 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: exploit some of those new smaps_rollup provisions

My, how time flies. Here we are finally attending to a
2 year old issue at long last (well, at least top is).

In truth, this change was prompted by that more recent
issue #201 and simply represents my initial picks from
among those available with the new library provisions.

Note: we have to bump that rcfile version whenever new
fields are added. That will mean older top programs no
longer can read this top's rcfile. But that's Ok since
top offers a warning before replacing an older rcfile.

Doubtless, more smaps_rollup fields will be introduced
under top as we get more experience with this feature.
However, any such usage comes with tremendoud costs as
was reported for the previous patch and repeated here:

Here is a small preview of just what you will discover
when using this command line: time top/top -d0 -n1000.

------------------------------------ as a regular user
    with only PID + RES (statm)
real       0m2.605s
user       0m1.060s
sys        0m1.377s
    with only PID + RSS (smaps)
real      0m26.397s                    10x more costly
user       0m1.253s
sys       0m24.915s

----------------- as a root (thus smaps for all tasks)
    with only PID + RES (statm)
real       0m2.651s
user       0m1.177s
sys        0m1.286s
    with only PID + RSS (smaps)
real      0m33.040s                    12x more costly
user       0m1.256s
sys       0m31.533s

Reference(s):
. top/ps: add support for PSS reporting
https://gitlab.com/procps-ng/procps/-/issues/112
. ps: expose shared/private memory separately
https://gitlab.com/procps-ng/procps/-/issues/201

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: add support for smaps_rollup file, <pids> api
Jim Warner [Mon, 26 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: add support for smaps_rollup file, <pids> api

A couple of people have suggested that smaps_rollup be
added to the ps program and/or top program. This patch
is intended to set the stage for just such extensions.

There are currently 20 displayable items in the rollup
file. And newlib sometimes uses sscanf when populating
the target, sometimes hsearch and one customized gperf
approach. None of these fit well with the smaps items.

Thus, an approach using a simple table lookup was used
and, by disabling 1 code line, it could be made immune
from changes to the items order (unlike a sscanf call)
and doesn't carry the greater cost of a hsearch/gperf.

Note: The next patch will allow top to display some of
these new fields. Then, it'll be possible to determine
the colossal costs of accessing the smaps_rollup file.

Here is a small preview of just what you will discover
when using the command 'time top/top -d0 -n1000' while
configured with just two fields: PID + 1 memory field.

------------------------------------ as a regular user
    with only PID + RES (statm)
real       0m2.605s
user       0m1.060s
sys        0m1.377s
    with only PID + RSS (smaps)
real      0m26.397s                    10x more costly
user       0m1.253s
sys       0m24.915s

----------------- as a root (thus smaps for all tasks)
    with only PID + RES (statm)
real       0m2.651s
user       0m1.177s
sys        0m1.286s
    with only PID + RSS (smaps)
real      0m33.040s                    12x more costly
user       0m1.256s
sys       0m31.533s

Reference(s):
. ps: expose shared/private memory separately
https://gitlab.com/procps-ng/procps/-/issues/201
. top/ps: add support for PSS reporting
https://gitlab.com/procps-ng/procps/-/issues/112

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: some miscellaneous tweaks before smaps_rollup
Jim Warner [Mon, 26 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: some miscellaneous tweaks before smaps_rollup

This commit is strictly cosmetic. It was an attempt to
normalize/standardize/alphabetize those #define/#undef
statements. Some missing #undef's were added plus some
comments regarding sources corrected/standardized too.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: extend end-of-job report to reflect unused fields
Jim Warner [Sun, 25 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: extend end-of-job report to reflect unused fields

In anticipation of adding some smaps_rollup stuff, our
end-of-job report will now offer some insight into the
current unused entries for a window's fieldscur array.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agovmstat: add guest time to stat
Christian Borntraeger [Wed, 28 Apr 2021 08:51:34 +0000 (18:51 +1000)]
vmstat: add guest time to stat

Since 2.6.24/33 the kernel knows about guest and guest nice time. That
is the time that is spend in KVM guests. To handle userspace programs
that do not know about this the guest time is also added to user.

Let us provide a guest time column in vmstat that collects both guest
and guest nice into a gu value.

We also subtract that value from the user time as we are now aware of
the guest value.

This commit is different to !113 in several ways:
 * newlib already knows about these to values
 * vmstat summary already shows these values
 * non-wide vmstat squishes the values

So its around the wide vmstat output.

References:
 procps-ng/procps!113
Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agolibrary: fix alignment with new 'io' types, <pids> api
Jim Warner [Sat, 24 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: fix alignment with new 'io' types, <pids> api

The commit referenced below was well done but needed a
small whitespace tweak to preserve existing alignment.

Reference(s):
. io accounting added
commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agomisc: Add NEWS item for previous
Craig Small [Sat, 24 Apr 2021 13:17:35 +0000 (23:17 +1000)]
misc: Add NEWS item for previous

3 years agops: Add IO Accounting fields
Craig Small [Sat, 24 Apr 2021 13:13:38 +0000 (23:13 +1000)]
ps: Add IO Accounting fields

Add the fields for the IO accounting to ps as the library now
has them added from previous commit.

References:
 commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

3 years agolibrary: adding IO accounting
Craig Small [Sat, 24 Apr 2021 12:38:48 +0000 (22:38 +1000)]
library: adding IO accounting

This is a modification of MR !122 by @renit1609 to fit the new
library.

Problem statement:
The procps library has no PROC_FILLIO flag to
fetch the proc field "/proc/[pid]/io" data
process-wise.
IO Accounting is not included as part of procps.

Requirement:
We have a requirement to fetch process wise
IO utilization which can be used for monitoring.

When looking through the procps library, I see
that IO Accounting (/proc/[pid]/io) is not being
included as part of procps. There is no such
flag like PROC_FILLIO being included in readproc.h .

Solution:
While looking at the implementation done for
other proc fields, I used the spare bits in app code.
I renamed PROC_SPARE_1 as PROC_FILLIO, the spare bit from
PROC_SPARE_* and used it for fetching /proc/[pid]/io
data as part of the procps library similar to other
fields. I moved the PROC_SPARE_* bits each by 1 bit
to retain the spare bits. Meanwhile added the IO fields
in proc_t structure.

References:
 procps-ng/procps!122
 procps-ng/procps#184

3 years agowatch.1: Correct long option for no linewrap.
Craig Small [Sat, 24 Apr 2021 02:01:49 +0000 (12:01 +1000)]
watch.1: Correct long option for no linewrap.

The correct long option for -w is --no-wrap but the man page
said it was --no-linewrap

References:
 procps-ng/procps#203

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agobuild-sys: find split systemd libraries
Christian Hermann [Wed, 14 Apr 2021 07:42:53 +0000 (09:42 +0200)]
build-sys: find split systemd libraries

With 4e7f4237 and 5e73c832, systemd library detection through pkg-config
was changed to unconditionally look for unified libsystemd.

This adds a fallback to match the previous behavior and find the split
libs as well.

References:
 procps-ng/procps!128

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agoescape.c: Fix missing nl_langinfo on certain configs
Issam E. Maghni [Sat, 24 Apr 2021 01:46:48 +0000 (11:46 +1000)]
escape.c: Fix missing nl_langinfo on certain configs

nl_langinfo and CODESET are undefined in a musl system. Instead of
uncondionally including langinfo.h, this change includes include/nls.h
which has the tests and work-arounds for systems that don't have these
features. This is similar to how other programs within procps include
langinfo.h via nls.h

References:
 procps-ng/procps!130

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agoconfigure: Add --disable-w
Issam E. Maghni [Fri, 23 Apr 2021 19:58:36 +0000 (15:58 -0400)]
configure: Add --disable-w

Some systems implement utmp as a stub so it doesn't make sense to have
a non-functioning w.  This change mitigates #193 and !126

References:
 procps-ng/procps!129
 procps-ng/procps!126
 procps-ng/procps#193

3 years agolibrary: fix an insidious bug affecting TICS_ALL_DELTA
Jim Warner [Thu, 22 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: fix an insidious bug affecting TICS_ALL_DELTA

This simple two line code change fixes an intermittent
bug whereby %CPU for parent(s) with collapsed children
could be vastly understated from those displayed under
the current 3.3.17 publicly available top & libprocps.

If one started several top instances in the background
using very a small delay interval (zero?), then if the
shell under which they were running was collapsed, you
would see similar %CPU results for both the libraries.

However, when running a demanding 'make' like a kernel
compile (especially if backed by fast processors and a
SSD), then newlib would generally show only 1/3 to 1/2
of the collapsed %CPU values that appeared for 3.3.17.

Of course, now that the bug has been swatted with this
commit the disparities between those results is easily
explained. Since newly created tasks never contributed
tics during the interval where they were created, only
with many short lived tasks would differences surface.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: lower addr resolution cost for TICS_ALL_DELTA
Jim Warner [Wed, 21 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: lower addr resolution cost for TICS_ALL_DELTA

Rather than run risks of more expensive and repetitive
address resolution, we will establish this local index
for a one time cost and avoid any potential gcc bloat.

[ this commit was made in pursuit of a bug involving ]
[ the distortion of elapsed task tics. but, it turns ]
[ out these changes had nothing to do with that bug. ]
[ however, the patch is being retained as desirable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: respond to library type change for TICS_ALL_DELTA
Jim Warner [Wed, 21 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: respond to library type change for TICS_ALL_DELTA

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: lessen chance of distortion on TICS_ALL_DELTA
Jim Warner [Wed, 21 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: lessen chance of distortion on TICS_ALL_DELTA

That old library defined this field as 'unsigned int'.
However, here it was known as a 'signed int'. Thus for
consistency we'll now also treat it as 'unsigned int'.

[ this commit was made in pursuit of a bug involving ]
[ the distortion of elapsed task tics. but, it turns ]
[ out these changes had nothing to do with that bug. ]
[ however, the patch is being retained as desirable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: fix a couple of spelling errors in new man pages
Jim Warner [Sat, 3 Apr 2021 05:00:00 +0000 (00:00 -0500)]
docs: fix a couple of spelling errors in new man pages

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: eliminate the #define VER_J_RCFILE as superfluous
Jim Warner [Wed, 31 Mar 2021 05:00:00 +0000 (00:00 -0500)]
top: eliminate the #define VER_J_RCFILE as superfluous

With that commit referenced below, which preserved the
'4' and + '!' toggles in the rcfile, this VER_J_RCFILE
macro was made superfluous. But, it was never removed.

Reference(s):
commit b46af6d21399a78f70e349c4476bd5545fbb44ce

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agopkill: Add lt- variants
Craig Small [Mon, 5 Apr 2021 04:40:00 +0000 (14:40 +1000)]
pkill: Add lt- variants

The pgrep code checks to see if the program is run as pkill or pidwait
and changes its behaviour accordingly.  Some older versions of libtool
run the programs as lt-pkill and lt-pidwait which means the tests fail.

We add these two program names to the checks.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agodocs: escape circumflex in sysctl.8
Craig Small [Mon, 29 Mar 2021 11:28:30 +0000 (22:28 +1100)]
docs: escape circumflex in sysctl.8

Groff says special characters should be escaped and some gettext
versions choke on it, so escape the ^

References:
 procps-ng/procps#147

3 years agobuild-sys: Handle zero length diskstats in tests
Craig Small [Mon, 29 Mar 2021 11:23:03 +0000 (22:23 +1100)]
build-sys: Handle zero length diskstats in tests

vmstat -d testsuite will fail if your /proc/diskstats is present
but zero length. While this seems buggy behaviour from lxcfs, its
there and its a simple matter to test for it and skip those tests
if we are run on a zero length /proc/diskstats system.

3 years agodocs: psr ps field is last run processor
Craig Small [Mon, 29 Mar 2021 11:11:27 +0000 (22:11 +1100)]
docs: psr ps field is last run processor

The ps.1 manpage incorrectly stated that psr field showed the
processor the process was assigned to. However if the assignment
has changed but the process has not run, then the field doesn't
change.

Some digging by @srikard showed it wasn't the processor assigned
but the last one it was run on. The man page now correctly
describes psr in that way.

References:
 procps-ng/procps#187

3 years agodocs: Explain sysctl --system better
Craig Small [Mon, 29 Mar 2021 11:07:08 +0000 (22:07 +1100)]
docs: Explain sysctl --system better

The sysctl.8 manpage explained the directory order but not that the
files were then ordered and run in lexiographic order no matter
the directory name.

References:
 procps-ng/procps#200

3 years agotop: replaced one use of fputs(3) with a write(2) call
Shaohua Zhan [Sun, 21 Mar 2021 16:00:00 +0000 (00:00 +0800)]
top: replaced one use of fputs(3) with a write(2) call

This patch is ported from a merge request shown below,
and the following represents the original commit text.

------------------------------------------------------
top: In the bye_bye function, replace fputs with the write interface.

When top calls malloc, if a signal is received, it will
call sig_endpgm to process the signal. In the bye_bye function, if the
-b option is enable, the Batch variable is set, the fputs function
will calls malloc at the same time. The malloc function is not reentrant, so
it will cause the program to crash.

Signed-off-by: Shaohua Zhan <shaohua.zhan@windriver.com>
------------------------------------------------------

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoslabtop: Check for bad d and o option combination
Craig Small [Thu, 11 Mar 2021 11:10:37 +0000 (22:10 +1100)]
slabtop: Check for bad d and o option combination

If you run slabtop with the -d option and then -o option the
delay gets set to zero and it runs forever. slabtop now checks
for this combination and errors.

Adding a DEJAGNU test also found that none of the slabtop
checks were running so they got added to the list and only the
ones that need /proc/slabinfo (if not readable) are skipped.

References:
 #160

3 years agow: Remove unreachable l option code
Craig Small [Thu, 11 Mar 2021 10:48:14 +0000 (21:48 +1100)]
w: Remove unreachable l option code

@ruihongw quite rightly pointed out we removed the l option
from the man page and getopt but the iunreachable case statement
remained.

References:
 commit 94468ac0b3be07495c1f4eccc9806bb812d93718
 #162

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agofree: Typo fix in error messages
Craig Small [Thu, 11 Mar 2021 10:45:14 +0000 (21:45 +1100)]
free: Typo fix in error messages

doesn't to don't

References:
 #195

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agomisc: needed adaptations for the changes in <pids> api
Jim Warner [Tue, 9 Mar 2021 06:00:00 +0000 (00:00 -0600)]
misc: needed adaptations for the changes in <pids> api

That snowball, which began as a simple removal of some
brackets, now ends with this third patch restoring the
ability to build our project. It was made necessary by
the renaming (and rearranging) of several enumerators.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: fix a few source/origin notations, <pids> api
Jim Warner [Tue, 9 Mar 2021 06:00:00 +0000 (00:00 -0600)]
library: fix a few source/origin notations, <pids> api

After removing brackets from those 'derived' notations
I was surprised to discover that several origin/source
comments were wrong. So this patch fixes those errors.

[ along the way a couple enumerators were renamed to ]
[ better (i hope) reflect what they're representing. ]

[ that, in turn, also required a little rearranging. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: clean 'derived' origins in header, <pids> api
Jim Warner [Tue, 9 Mar 2021 06:00:00 +0000 (00:00 -0600)]
library: clean 'derived' origins in header, <pids> api

None of the other four new api headers use brackets on
derived items. With this patch we normalize the fifth.

[ it makes for a cleaner, less confusing, appearance ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: enabled arbitrarily large numbers in 'scale' guys
Jim Warner [Mon, 8 Mar 2021 12:08:21 +0000 (06:08 -0600)]
top: enabled arbitrarily large numbers in 'scale' guys

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

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: Add OOM and OOMADJ fields
Craig Small [Fri, 5 Mar 2021 06:22:29 +0000 (17:22 +1100)]
ps: Add OOM and OOMADJ fields

top has had the OOMs and OOMa fields since 2011. Ten years its
probably time that ps had these fields added too.

ps output options have oom and oomadj for OOM Score and OOM Adjustment
respectively.

References:
 procps-ng/procps#198
 commit 367fd902dab64b51ba49709004b5011440e3105a
 https://www.freelists.org/post/procps/PATCH-12-Add-missed-oom-support-to-libproc

3 years agolibrary: tweaked key used in hash table, <meminfo> api
Jim Warner [Tue, 23 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: tweaked key used in hash table, <meminfo> api

This small change was a result of some experimentation
trading our current 'hsearch' hash scheme for 'gperf'.

I discovered that when the ':' character was a part of
each 'gperf' key, that generated search logic was more
complicated and thus slower. But without a ':', it was
a little cleaner/leaner and therefore slightly faster.

Assuming that the same trailing ':' *might* affect the
current 'hsearch' logic, to be safe we will remove it.

[ while the 'gperf' version will slightly outperform ]
[ an 'hsearch', too many ugly implementation details ]
[ were exposed which complicates future maintenance. ]

[ thus, we'll retain our current 'hsearch' approach. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: normalized the 'read_failed' guys across APIs
Jim Warner [Mon, 22 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: normalized the 'read_failed' guys across APIs

This patch will condense some logic in those functions
associated with the file input operations. The changes
will not, for the most part, alter any generated code.

More significantly (though not very) was the change to
two 'strtoul' calls. Since the returned 'endptr' value
isn't exploited, when that parm is set to NULL, we can
save one instruction on each side of such calls (wow).

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agobuild-sys: Fix the uninstall-man target
Craig Small [Wed, 24 Feb 2021 09:58:28 +0000 (20:58 +1100)]
build-sys: Fix the uninstall-man target

If automake doesn't see a dist_man_MANS then there is no
uninstall-man target. This fix uses the main Makefile
targets.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotests: Fix paths for testsuite
Craig Small [Wed, 24 Feb 2021 09:41:38 +0000 (20:41 +1100)]
tests: Fix paths for testsuite

make distcheck gets confused what is in srcdir and what is in
topdir

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agodocs: tweak two man pages due to renaming of libproc-2
Jim Warner [Sat, 20 Feb 2021 17:11:11 +0000 (11:11 -0600)]
docs: tweak two man pages due to renaming of libproc-2

Reference(s):
commit 9aa09d8862c00a8dc85910d0365332c8c99b59ce

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: eliminate a useless conditional in readproc.h
Jim Warner [Thu, 18 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: eliminate a useless conditional in readproc.h

When #define QUICK_THREADS was introduced, for copying
some task data for a child thread, one proc_t pad byte
was used to mark, then later identify, those children.

Later the QUICK_THREADS was recycled as FALSE_THREADS,
and used for a different purpose, but a conditional in
the header file erroneously remained. Now, it is gone!

Reference(s):
. Jul, 2016 - QUICK_THREADS become FALSE_THREADS
commit c546d9dd4409ee11cd466c99a820a3b5dadfe3f4
. Aug, 2011 - QUICK_THREADS intruduced
commit bb4f08ba297a67a043f7547670aa8623b54c2e67

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