Commit Graph

2291 Commits

Author SHA1 Message Date
Jim Warner
4b54518721 top: enabled arbitrarily large numbers in 'scale' guys
While experimenting with a new feature, wherein select
fields display the total upon request, the capacity of
the 'num' passed to some 'scale' guys became an issue.

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

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Jim Warner
e03be322b5 top: a silly change forcing right margin justification
Reference(s):
. 01/11/21, newlib branch equivalent commit
commit 0cf6942be7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Jim Warner
5ae84fac6e top: allow setting variable width col scroll (1 vs. 8)
The Inspection feature already offered an INSP_SLIDE_1
provision. This patch now offers similar extensions to
variable width column scrolling (assuming SCROLLVAR_NO
isn't defined). Such a provision was useful during the
development of some recent library UTF-8 enhancements.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-01-17 20:27:20 +11:00
Todd Lewis
401d587d2d fix uid/gid > 2^31 2021-10-25 19:38:10 -04:00
Tommi Rantala
23da4f40ea 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
2021-10-13 20:47:44 +00:00
Craig Small
fc960774d5 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>
2021-10-13 07:59:04 +11:00
Jim Warner
aa3348db86 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>
2021-10-08 18:19:17 +11:00
Jim Warner
d7e6c27a79 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>
2021-10-02 13:01:15 +10:00
Craig Small
474847ed35 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>
2021-09-13 22:07:37 +10:00
Jim Warner
271004bd0d 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>
2021-09-08 21:35:54 +10:00
Jim Warner
24bb9227ac NEWS: update to acknowledge top's long cmdline options
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-09-07 08:01:25 +10:00
Jim Warner
dbc6532128 top: update man document with new long cmdline options
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-09-07 08:01:25 +10:00
Jim Warner
016ddc6bff 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>
2021-09-07 08:01:25 +10:00
Jim Warner
43f1cc0dcf top: some minor organizational tweaks for man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-09-07 08:01:25 +10:00
Jim Warner
2480bc0221 top: and just eliminate a couple of unnecessary braces
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-24 20:53:27 +10:00
Jim Warner
2c3b251b11 top: reposition call to cpus_refresh() for consistency
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-24 20:53:27 +10:00
Jim Warner
97ef7fe504 top: corrected some more miscellaneous man page errata
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-24 20:53:27 +10:00
Jim Warner
3b69883c07 top: whack a label & branch in 'summary_show' function
Catch-up with newlib, original commit message follows:
------------------------------------------------------

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>
2021-08-24 20:53:27 +10:00
Jim Warner
7a30fd0f51 top: added a new #define to test absence of numa nodes
Catch-up with newlib, original commit message follows:
------------------------------------------------------

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>
2021-08-24 20:53:27 +10:00
Jim Warner
6b4e4a006c top: man page reflects '-H' impact for '-p' provisions
Reference(s):
https://www.freelists.org/post/procps/important-extension-to-newlib,4

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-17 22:06:57 +10:00
Jim Warner
bddc9fb3e6 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 9dd7a97c4a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-17 22:06:57 +10:00
Jim Warner
5e6b354a0c top: document summary area changes involving 2 abreast
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-06 20:19:18 +10:00
Jim Warner
8ef60b84af 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 fca48e7e99

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-06 20:19:18 +10:00
Jim Warner
c725207c44 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>
2021-08-06 20:19:18 +10:00
Jim Warner
d19ee838a6 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>
2021-08-01 20:39:46 +10:00
Jim Warner
02a4220a56 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>
2021-08-01 20:39:46 +10:00
Jim Warner
bdd50fa2fc 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 ]
[ that prologue for 'forest_display' since all other ]
[ forest functions used punctuation. And, instead of ]
[ a pointer to a proc_t he will now get a ppt index. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-08-01 20:39:46 +10:00
Jim Warner
37f1060299 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 merged change
commit 0bf15c004d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-06-23 18:24:50 +10:00
Jim Warner
dc8137f85b 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 84e85611c3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-06-17 16:46:33 +10:00
Craig Small
64578746f6 Merge branch 'ericonr/procps-error'
References:
 procps-ng/procps!137
2021-06-16 20:02:18 +10:00
Érico Nogueira
67eddacfc9 c: print strerror() instead of error code.
This changes error() behavior to match what glibc already does.
2021-06-16 20:01:46 +10:00
Craig Small
48b977f2dc Merge branch 'heftig/procps-fix-free-h-si'
References:
 procps-ng/procps!140
 procps-ng/procps#133
2021-06-16 19:45:31 +10:00
Jan Alexander Steffens (heftig)
91e5879228
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
2021-06-15 21:42:51 +02:00
Jim Warner
84e85611c3 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>
2021-06-02 20:06:32 +10:00
Jim Warner
e400f0be47 top: extend end-of-job report to reflect unused fields
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-06-02 20:06:32 +10:00
Jim Warner
7086e99067 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 f858e563b7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-06-02 20:06:32 +10:00
Bas van der Vlies
9f0d1c8b8f 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 ...
```
2021-05-29 06:17:43 +00:00
Henrik Grimler
859b63f815 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.
2021-05-26 15:45:02 +02:00
Jan Rybar
a1bc3bf207 Coverity scan findings - memleaks, unused vars, potential nullptr dereferences 2021-05-06 16:32:11 +02:00
Issam E. Maghni
2763b9880a escape.c: Fix missing nl_langinfo on certain configs 2021-04-24 01:43:46 +00:00
Issam E. Maghni
1524a625e6 configure: Add --disable-w 2021-04-23 16:27:30 -04:00
Shaohua Zhan
0bf15c004d 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>
2021-03-18 15:46:46 +08:00
Craig Small
52afb3a8d3 pidwait: Rename from pwait
pwait is already in at least Debian in a different package

References:
 https://bugs.debian.org/982391
2021-02-15 21:10:06 +11:00
Jim Warner
19a508ea12 NEWS: tweak wording associated with library versioning
Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-02-09 16:38:47 +11:00
Craig Small
1f74877096 library: Version has revision incremented
Library had only its revision incremented to three as there were only
internal changes.

References:
 commit 0d386260b4
 commit eea5626bb1
 commit 1b9ea61116
 commit b0c8e3408b
 commit e319650278
 commit bb1a79f2c8
 commit b52a267404
 commit 8e0c33be46

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-02-08 21:36:05 +11:00
Craig Small
f9dd869a3e build-sys: Don't require po4a for installation
The build system tested for the presence of po4a binary at the
install step. procps ships with translated man pages so doesn't
need po4a for install/uninstallation.

Works already in psmisc!

References:
 5fab6b7ab3

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-02-08 21:23:41 +11:00
Craig Small
73f1f65761 nls: Fix translation problems
Some of the translation files did not escape the < properly leading
to po4a aborting.  Also some translators are using old templates
and this merges them to the new ones.

References:
 procps-ng/procps#188
2021-01-30 10:38:30 +11:00
Craig Small
fffcc4e972 nls: Update the translation files
Download of the translation files from the translation
project.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2021-01-28 22:39:49 +11:00
Craig Small
f0c5cf279d build-sys: Ignore temp directory for POTFILES.in
Sometimes the testing sequence would leave a source tree
under procps-ng-(version) which, if update-potfiles was
run, would include these temporary files in the list, causing issues
later.

The script now explicitly ignores those temporary files.
2021-01-28 22:35:33 +11:00
Craig Small
0ffb087214 misc: Update NEWS to next version 2021-01-22 18:21:08 +11:00