]> granicus.if.org Git - procps-ng/log
procps-ng
3 years agopmap: minor Coverity fix for -N option
Craig Small [Tue, 2 Nov 2021 06:14:29 +0000 (17:14 +1100)]
pmap: minor Coverity fix for -N option

99126 Explicit null dereferenced
Not 100% sure this is valid (the same branch that sets the variable
is the one that sets N_option) but not too hard to fix.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotop: tweak some end-of-job logic when separate threads
Jim Warner [Thu, 28 Oct 2021 05:00:00 +0000 (00:00 -0500)]
top: tweak some end-of-job logic when separate threads

The separate threads for background updates were added
to top in the commit shown below. At that time cleanup
logic was added to end-of-job processing to cancel any
active threads and destroy any semaphores then in use.

That seemed like simple good stewardship with an added
benefit of avoiding potential valgrind 'possibly lost'
warnings for 320 byte blocks. Those blocks represented
an initial stack allocation for each of three threads.

All of that worked perfectly if such code was executed
under the main thread. In other words, if the keyboard
or a signal directed to any thread was used to trigger
program end. However, it might not always be the case.

Each of those 'refresh' routines supporting a separate
thread interacts with a newlib interface. As a result,
each is required to check the library's return result.
Should some error be detected, 'error_exit' is called.
Now we've got big problems with that eoj cleanup code.

One can't 'pthread_cancel' and 'pthread_join' a thread
from withing that same thread. Thus, when an error was
returned by the library with threads active, top would
hang with no possibility of removal short of a reboot.

So, this commit only executes that cancel/join cleanup
code when we are running under the main thread. Should
program end be triggered by a library error under some
sibling thread, all such cleanup will now be bypassed.
In the latter case, we will rely on documentation that
says any thread calling exit(3) will end every thread.

[ now, the only time we'll see any valgrind warnings ]
[ is with a library error, which is the least likely ]
[ scenario for running valgrind & top to begin with. ]

[ besides, if the valgrind warnings became a problem ]
[ one could easily add a 'warning-suppression' file. ]

Reference(s):
. Sep 2021, top introduced threads
commit 29f0a674a85bfb92443c56f070956a7dd60bb5f7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: remedy several 'coverity scan' resource leaks
Jim Warner [Wed, 27 Oct 2021 05:00:00 +0000 (00:00 -0500)]
library: remedy several 'coverity scan' resource leaks

This commit will place the 'file2strvec' function on a
par with the 'file2str' function if ENOMEM was raised.

Plus, just to keep coverity happy, we'll also clean up
after potential failures with the 'openproc' function.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: oh no, failed to right-justify 1 comment line
Jim Warner [Wed, 27 Oct 2021 05:00:00 +0000 (00:00 -0500)]
library: oh no, failed to right-justify 1 comment line

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agopgrep: Match on cgroup v2 paths
Craig Small [Tue, 26 Oct 2021 09:56:19 +0000 (20:56 +1100)]
pgrep: Match on cgroup v2 paths

You can match or filter on cgroup paths. Currently the match is only
done for version 2 cgroups because these are way simpler as they have
a unified name and always start with "0::".

cgroup v1 can have:
 named groups "1:name=myspecialname:"
 controllers "9:blkio:"
 multiple controllers! "4:cpu,cpuacct:"

So they are very much more complicated from a options parsing and
cgroup matching point of view.

In addition, both my Debian bookworm and bullseye systems use
v2 cgroups.

$ ./pgrep --cgroup /system.slice/cron.service
760

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agoNEWS: Add entry for free -h --si fix
Craig Small [Tue, 26 Oct 2021 07:25:37 +0000 (18:25 +1100)]
NEWS: Add entry for free -h --si fix

References:
 commit 91e58792282d676fbcb3781d2ed48d6b082c6c56
 Issues #133 #223
 merge !140

3 years agofix uid/gid > 2^31
Todd Lewis [Mon, 25 Oct 2021 23:38:10 +0000 (19:38 -0400)]
fix uid/gid > 2^31

This MR revisits a partial fix from 2018. The problem stems from incorrect
handling of unsigned 32-bit uid_ts and gid_ts as signed when values are
large - i.e. when the high bit is set. In that case, pgrep and pkill fail to
identify processes by uid. (They succeed when finding the same processes by
username.) The primary fix for this is to impliment the "FIXME" comment in
proc/readproc.h, the implementation of which allows the removal of the (int)
casts from the partial fix from 2018.

The other fixed code in this MR consists of tests in strict_atol() that
detects and errors out on overflows.

References:
 Merge !146

3 years agolibrary: expand warnings in 'warning-suppression' file
Jim Warner [Fri, 22 Oct 2021 05:00:00 +0000 (00:00 -0500)]
library: expand warnings in 'warning-suppression' file

With the addition of more '__thread' attributes in the
previous commit, additional valgrind warnings might be
encountered if developing multi-threaded applications.

So, this patch expands the libproc.supp file which was
originally introduced with the patch referenced below.

Reference(s):
commit be1ddc275623b6cf16060d8a0fa1fb36f677010a

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: extend thread safety to more static variables
Jim Warner [Fri, 22 Oct 2021 05:00:00 +0000 (00:00 -0500)]
library: extend thread safety to more static variables

In the commit referenced below, a '__thread' attribute
was added to numerous static variables to protect them
from concurrent access conflicts with multi-threading.

Unfortunately, that patch did not go quite far enough.

So, this commit adds a few more '__thread' qualifiers.

Reference(s):
commit 23cfb7136636f2d522b31417892de79b011ad3e4

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodoc: added the new valgrind 'warning-suppression' file
Jim Warner [Thu, 14 Oct 2021 05:00:00 +0000 (00:00 -0500)]
doc: added the new valgrind 'warning-suppression' file

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: created a valgrind 'warning-suppression' file
Jim Warner [Thu, 14 Oct 2021 05:00:00 +0000 (00:00 -0500)]
library: created a valgrind 'warning-suppression' file

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: only use 'pthread_sigmask' under separate threads
Jim Warner [Thu, 14 Oct 2021 05:00:00 +0000 (00:00 -0500)]
top: only use 'pthread_sigmask' under separate threads

When multi-threading was introduced in the patch shown
below, the former calls to sigprocmask were traded for
a pthread_sigmask call. This was done unconditionally.

As a result, even when those threads weren't enabled a
need to link with libpthread was created. In hindsight
the need should only arise when top is multi-threaded.

This commit will make pthread_sigmask use conditional.

Reference(s):
. 09/2021, separate threads introduced
commit 29f0a674a85bfb92443c56f070956a7dd60bb5f7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agouptime: Correctly print pretty/short format
ed neville [Thu, 14 Oct 2021 08:37:42 +0000 (19:37 +1100)]
uptime: Correctly print pretty/short format

uptime -p would show empty output after 52 weeks of uptime. This commit
is largely the work of Ed but reformatted for newlib branch.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
References:
 procps-ng/procps!141
 procps-ng/procps#217

3 years agovmstat: Add NEWS and man page for previous
Craig Small [Thu, 14 Oct 2021 07:52:34 +0000 (18:52 +1100)]
vmstat: Add NEWS and man page for previous

3 years agovmstat: Provides option to omit first report
Sanskriti Sharma [Wed, 8 Aug 2018 15:48:32 +0000 (11:48 -0400)]
vmstat: Provides option to omit first report

The first report from vmstat provides statistics since system boot. This is
often thrown out. Thus, this provides a command line option to omit it. The
program still provides <count> reports.

Signed-off-by: Sanskriti Sharma <sansharm@redhat.com>
3 years agomisc: Fix typo
林博仁(Buo-ren, Lin) [Tue, 23 Feb 2021 03:02:10 +0000 (03:02 +0000)]
misc: Fix typo

Signed-off-by: 林博仁(Buo-ren, Lin) <Buo.Ren.Lin@gmail.com>
3 years agomisc: Add NEWS for ps ignoring SIGURG
Craig Small [Wed, 13 Oct 2021 20:52:43 +0000 (07:52 +1100)]
misc: Add NEWS for ps ignoring SIGURG

References:
 commit b6ccf865f83f98478a814c1d79d17a0b5212cc6e

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

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

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

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

3 years agoRemove autogen.sh libtool prog check #222.
Rafael Kitover [Mon, 11 Oct 2021 20:23:12 +0000 (20:23 +0000)]
Remove autogen.sh libtool prog check #222.

Remove the check for the libtool executable as many libtool distribution
packages do not have it and it is not necessary for building, as
libtoolize is also checked for to determine the presence of libtool.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
3 years agotestsuite: Make test program compile on Hurd
Craig Small [Tue, 12 Oct 2021 20:56:39 +0000 (07:56 +1100)]
testsuite: Make test program compile on Hurd

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

Thanks to Svante Signell for the patch.

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

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

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

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

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: revert part of a patch regarding separate threads
Jim Warner [Thu, 30 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: revert part of a patch regarding separate threads

In the patch referenced below, some logic was moved in
that frame_make function in an effort to overlap those
background threads with additional main thread duties.

Unfortunately, the auto-size column feature was broken
in the process. So this patch will revert a portion of
the earlier patch so as to restore the broken feature.

Reference(s):
. Sep 2021, top overlap additional processing
commit f11f43b4f7118f284f9aec19f6885d163848ffe7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: ensure thread safety via function substitutes
Jim Warner [Tue, 28 Sep 2021 05:00:00 +0000 (00:00 -0500)]
library: ensure thread safety via function substitutes

Even though we we had to abandon the master branch top
multi-thread effort and even though the newlib version
of a multi-threaded top provides no real benefit, that
whole exercise was not wasted. Rather, it has revealed
some deficiencies in our library which this addresses.

If two or more threads in the same address space tried
to use procps_loadavg or procps_uptime simultaneously,
there's a chance they would experience problems due to
thread-unsafe functions our library called internally.

So, this patch switches them for thread-safe versions.

[ along the way we will also make that procps_uptime ]
[ initialization of his 'up' & 'idle' variables mean ]
[ something by delaying the -ERANGE return a little. ]

Reference(s):
https://www.freelists.org/post/procps/a-few-more-patches,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: ensure thread safety for all static variables
Jim Warner [Tue, 28 Sep 2021 05:00:00 +0000 (00:00 -0500)]
library: ensure thread safety for all static variables

Even though we we had to abandon the master branch top
multi-thread effort and even though the newlib version
of a multi-threaded top provides no real benefit, that
whole exercise was not wasted. Rather, it has revealed
some deficiencies in our library which this addresses.

If two or more threads in the same address space tried
to access the same api simultaneously, there is a good
chance some function-local static variables will yield
some of those renowned unpredictable results. So, this
patch protects them with the '__thread' storage class.

Reference(s):
https://www.freelists.org/post/procps/a-few-more-patches,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: ensure those potential focused tasks stay focused
Jim Warner [Thu, 23 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: ensure those potential focused tasks stay focused

When that 'F' focus command has been applied to a task
in forest view it should remain as the topmost process
in a particular window. But without this patch that is
not guaranteed. Newly forked/cloned tasks 'above' such
a process result in task(s) appearing which shouldn't.

The effect was as if that up arrow key scrolled beyond
the topmost parent task, which would never be allowed.

[ since scrolling is permitted within a focus range, ]
[ when any task 'above' our focus/topmost task ends, ]
[ we respond as if scrolled with the down arrow key. ]

[ that result is completely appropriate. if the user ]
[ wishes to return to a focused parent, the up arrow ]
[ or home key can be used to accomplish such a goal. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: overlap some more processing for separate threads
Jim Warner [Wed, 22 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: overlap some more processing for separate threads

In an effort to improve the performance & decrease the
cost of our separate background update threads we will
relocate some overhead so that it might be overlapped.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: modify semaphore destruction for separate threads
Jim Warner [Tue, 21 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: modify semaphore destruction for separate threads

This commit just ensures that at program end all those
semaphores are removed in the same order for symmetry.
From thread's view of importance, we do least to most.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: reverse the #define defaults for separate threads
Jim Warner [Sun, 19 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: reverse the #define defaults for separate threads

Rather than having those 3 separate background threads
enabled by default, we'll turn them off until somebody
chooses to activate them. That seems more appropriate.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: introduce background updates via separate threads
Jim Warner [Sat, 18 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: introduce background updates via separate threads

After the stage had been set in the previous patch, in
this patch we will actually implement those background
updates via 3 separate threads. The design was simple:

. the do-while loops have now been made truly infinite
. 2 semaphores per thread allow needed synchronization
. 1 semaphore will provide for each thread to sem_wait
. 1 semaphore will provide for display o/p to sem_wait
. and all 3 thread's program name was made descriptive

A complication was the potential for a signal directed
to one of our new threads. Rather than having a thread
try to deal with such signals, we pass a mask with all
signals blocked at pthread_create time. Thereafter any
subsequent signals are forwarded to the parent thread.

[ also sigprocmask was exchanged for pthread_sigmask ]
[ since warned about use "in multithreaded process". ]

[ plus we also modified each of those POSIX comments ]
[ about 2004 to agree with current signal-safety(7). ]

Sadly, after all this effort there were no performance
benefits to having separate threads. In fact there was
a measurable performance degradation when running with
ever smaller delay intervals. But even with a delay of
1/10 second the 'real' cost increase is only about 1%.

There is one way whereby any additional costs might be
eliminated (at least seemingly). One could introduce 2
separate sets of contexts for each of those 3 threads.
Then retrieval & display could be overlapped. However,
the resulting display wouldn't represent the real-time
results. Rather it would be stale by 1 delay interval.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: refactor 3 routines ahead of the separate threads
Jim Warner [Sat, 18 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: refactor 3 routines ahead of the separate threads

This commit sets the stage for turning three functions
into code that can support a separate thread to update
their respective data while working in the background.

It involved relocating 1 function, renaming 2 routines
and adding parameters plus return addresses to each of
three functions. Those latter changes will be required
when issuing 'pthread_create' calls in the next patch.

The final step was organizing this code into what will
become the infinite do-while loop supporting a thread.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: tweak end-of-job processing if invoked via signal
Jim Warner [Thu, 16 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: tweak end-of-job processing if invoked via signal

The master branch top is pretty well insulated against
signal-unsafe function calls during end-of-job action.

However, this newlib branch top had exposed himself to
a bunch of such unsafe activity in the form of 'unref'
function calls to the new library. In those guys there
will be several 'free' invocations which are not safe.

So, this commit will simply correct such an oversight.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: justify those header #define description comments
Jim Warner [Tue, 14 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: justify those header #define description comments

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

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: Add note in sysctl.conf.5 for line length
Craig Small [Wed, 15 Sep 2021 11:45:26 +0000 (21:45 +1000)]
docs: Add note in sysctl.conf.5 for line length

References:
 procps-ng/procps#77

3 years agodocs: Fix comment for priority
Craig Small [Wed, 15 Sep 2021 11:36:40 +0000 (21:36 +1000)]
docs: Fix comment for priority

Adjust the pri field for ps.1 because a higher pri field means a
higher priority.

References:
 procps-ng/procps#115

3 years agosysctl: Return non-zero if param setting failed
Jan Rybar [Wed, 15 Sep 2021 11:07:43 +0000 (21:07 +1000)]
sysctl: Return non-zero if param setting failed

Real usecase:
'sysctl -w user.max_uts_namespaces=2147483648; echo $?'
returns 0 even though it failed with EINVAL

The close_stream() realised there was an issue and printed an
error but didn't change the return value.

Slightly modified merge request.

References:
 procps-ng/procps!76

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agomisc: Add NEWS for previous
Craig Small [Wed, 15 Sep 2021 10:54:30 +0000 (20:54 +1000)]
misc: Add NEWS for previous

References:
 procps-ng/procps!91

3 years agopgrep: Add a newline after regex error messages
Tom Levy [Fri, 1 Nov 2019 02:17:54 +0000 (02:17 +0000)]
pgrep: Add a newline after regex error messages

The message from 'regerror' does not include a newline.

Test with `pgrep '*'`.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotestsuite: Add sysctl test for directory checks
Craig Small [Wed, 15 Sep 2021 10:16:06 +0000 (20:16 +1000)]
testsuite: Add sysctl test for directory checks

Adds a test to try to write a sysctl parameter above /proc
and passes if it gives an error message.

References:
 commit f25d462166f80b844d33dad3e4c06088c809a426

3 years agosysctl: Update previous patch for newlib
Craig Small [Wed, 15 Sep 2021 10:09:44 +0000 (20:09 +1000)]
sysctl: Update previous patch for newlib

This change was cherry picked from old library branch but
missed the change to check the path.

References:
 commit 6389deca5bf667f5fab5912acde78ba8e0febbc7

3 years agosysctl: Support systemd glob patterns
Craig Small [Mon, 13 Sep 2021 12:07:37 +0000 (22:07 +1000)]
sysctl: Support systemd glob patterns

systemd-sysctl handles glob patterns along with overrides and
exceptions. Now the procps sysctl does it too.

The return value for sysctl is consistently either 0 or 1.

Added tests to check sysctl functions.

References:
 procps-ng/procps#191

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotop: some minor tweaks supporting long cmdline options
Jim Warner [Wed, 8 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: some minor tweaks supporting long cmdline options

This darn patch began as 1 correction to an extraneous
comma in the man document. Then, it grew to include an
adjustment for a couple of additional man page things.

After that, I figured I might as well tighten up logic
dealing with those awful gaps in the getopt_long code.

[ the error_exit mentioned in the associated comment ]
[ will only be taken when '=' ends the argv vectors! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoNEWS: update to acknowledge top's long cmdline options
Jim Warner [Sat, 4 Sep 2021 05:00:00 +0000 (00:00 -0500)]
NEWS: update to acknowledge top's long cmdline options

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: update man document with new long cmdline options
Jim Warner [Sat, 4 Sep 2021 05:00:00 +0000 (00:00 -0500)]
top: update man document with new long cmdline options

Signed-off-by: Jim Warner <james.warner@comcast.net>
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.