Commit Graph

2864 Commits

Author SHA1 Message Date
Jim Warner
0df22d89db doc: make the library API pages a little more readable
Use of the the '.B' and '.BI' man documentation macros
had rendered the three library API pages less readable
than they could be. In addition, sometimes the pointer
indicator and an identifier were separated by a space.

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

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-07-27 20:24:54 +10:00
Craig Small
813cefe96a nls: Update po files
Updates to cover the "new used" change and the pidwait change
2022-07-18 20:55:01 +10:00
Craig Small
95a253aa6e pgrep: Better warning if pidfd_open not implemented
If procps is built on a Linux 5.3+ system then pidwait
is built with pidfd_open(). If that program is run on
a system < 5.3 then it gives an odd generic error.

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

The man page is updated to note this issue.

This came up due to killall in psmisc using pidfd_send_signal

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-07-18 20:51:41 +10:00
Craig Small
bcce3e440a ps: Make STIME entries thread safe
Using localtime() can be a problem due to the static buffer for
the return value. It's simple enough to use localtime_r()

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-06-30 21:15:37 +10:00
Jim Warner
b0adacf1ea top: if line editing, account for invisible characters
If we're deleting a character or operating in overtype
mode, we must account for the potential of 'invisible'
characters. When one follows any character about to be
deleted or replaced both multi-byte sequences must go.

Without this change, there exists the possibility that
top might report some error where no error is apparent
to the user. For example, with 'other filtering' (o/O)
the user could see "unrecognized field name 'COMMAND'"
where the quoted column name appears perfectly normal.

Or maybe a sequences like the 'combining acute accent'
gets applied to an existing character instead of being
deleted as one expects when its parent was eliminated.

So, henceforth whenever any character is being deleted
we will now check for a following 'invisible' sequence
then eliminate it along with that preceding character.

[ admittedly, these scenarios are very rare yet they ]
[ may occur, especially when recalling some previous ]
[ multi-byte strings for editing. and, since we will ]
[ be interacting with a user, performance won't be a ]
[ factor so extra checks for a zero wcwidth is fine. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-30 20:55:27 +10:00
Jim Warner
8920078407 top: adjust the man page alignment for 'Ctrl' commands
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-26 19:22:00 +10:00
Jim Warner
757a345209 top: afford another level of protection for line input
This commit just provides the final protection against
possible screen corruption when processing line input.

[ such corruption was limited to the input line only ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-26 19:22:00 +10:00
Craig Small
8ca346762d doc: Note new Used behavour
Added note to NEWS in the lbirary section
Updated free.1 as it specifies the calculation

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-06-25 11:42:08 +10:00
Jim Warner
047d16ccfd top: adapt for modification to 'MEMINFO_MEM_USED' item
With the library change calculating 'MEMINFO_MEM_USED'
top must be tweaked in order to retain the distinction
between non-cached used memory and cached used memory.

[ assuming one of the two graphs are being displayed ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-25 11:32:18 +10:00
Jim Warner
2184e90d2e library: modify calculation of 'MEMINFO_MEM_USED' item
In an effort to more accurately reflect 'used' memory,
we will now rely on the kernel's estimate of available
memory. Thus, 'MEMINFO_MEM_USED' will be calculated as
just 'MEMINFO_MEM_TOTAL' less 'MEMINFO_MEM_AVAILABLE'.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-25 11:32:18 +10:00
Jim Warner
3c7f8199f7 top: adjust some parenthesis for correct '^N' behavior
Some kdeinit tasks have a large environment consisting
mostly of nulls which were then followed by one or two
printable characters. Such strange environments should
not be shown with that 'not applicable' (n/a) notation
even though that first string vector is equal to '\0'.

I thought I had covered such a contingency but, due to
a misplaced right parenthesis, that '^N' bottom window
could see 'n/a' + a bunch of spaces + printable stuff.

Well, that won't happen anymore with this tiny change.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-20 19:18:02 +10:00
Jim Warner
daaf634eb3 top: make 'n/a' (not applicable) notation translatable
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-20 19:18:02 +10:00
Jim Warner
2282c74c33 NEWS: acknowledge that utf8 multi-byte character input
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-14 21:52:14 +10:00
Jim Warner
c20fef1d7d top: enable processing utf8 multi-byte character input
This program was well equipped to properly handle utf8
multi-byte characters - except for one important area!

If users typed any unicode character (shift+ctrl+u) or
pasted a utf-8 multi-byte string as a response to some
input prompt, those characters would simply be ignored
since they would not pass the internal 'isprint' test.

Well, now we can handle such data while preserving all
line editing provisions such as insertions, deletions,
destructive backspace, prior line recall (up/down) and
those all important cursor left plus right arrow keys.

[ we even support overtype mode for multi-byte stuff ]
[ even though our gui emulator will not let us alter ]
[ the cursor as confirmation (as we do at a console) ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-14 21:52:13 +10:00
Jim Warner
970a3dc990 top: provide for visual hint when overtype mode active
Given that we won't always be able to alter the cursor
shapes (from underscore to block) if in input overtype
mode, this commit will at least provide a visual clue.

[ while this libvte quirk will impact gnome-terminal ]
[ and likely others, we're able to change the cursor ]
[ shape from underscore to block at a linux console. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-14 21:52:13 +10:00
Jim Warner
f40fc402d4 top: avoid premature forced loss of that bottom window
In the commit shown below the bottom window was forced
off if a full screen replacement function was invoked.
It did so by setting Frames_signal after calling those
routines from the keys_global function. However, there
was sometimes a possibility such action was premature.

At least two of those full screen replacement routines
may issue an error message & return without corrupting
the screen. As such, forcing off that bottom window is
totally unnecessary. It therefore should be preserved.

So this commit just moves the setting of Frames_signal
to the full screen replacement routines when possible.

Reference(s):
. May, 2022 - bottom window forced off for some
commit d66c1f39b5

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-14 21:52:13 +10:00
Jim Warner
60bac2b544 doc: acknowledge the top 'message log' display ability
[ along the way, we'll fix-up the section 4 commands ]
[ summary which has gotten a little outdated lately. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-05 21:11:38 +10:00
Jim Warner
3901dcb9c9 top: provides a new user 'message log' display ability
Messages issued by top will be displayed for only 1.25
seconds. And while this length of time would appear to
be acceptable (given the absence of complaints), there
will be times when a specific message might be missed.

So, this commit offers users the opportunity to recall
up to 10 of the most recent messages that were issued.

[ we'll just exploit top's new bottom window feature ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-05 21:11:38 +10:00
Jim Warner
15a6203b00 library: at unref, close these cached file descriptors
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-06-05 21:11:38 +10:00
Craig Small
f8f3ea2527 library: Close filehandle for procps_loadavg
Previous commit didn't close the filehandle after making the
open non-persistent.

References:
 commit 8fcd14de18
2022-06-02 16:36:40 +10:00
Craig Small
ce0286daca library: clear rc in procps_loadavg again
During the changes to procps_loadavg I didn't set the initial
value for retval, meaning it was a random number.
It is now correctly intialised to zero.

References:
  commit 8fcd14de18
2022-05-31 22:03:22 +10:00
Craig Small
3111334ddd tload: Report on lack of /proc/loadavg
Now that the library correctly returns an error if loadavg
is not available, tload can tell the user the bad news.

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-05-31 21:35:40 +10:00
Craig Small
8fcd14de18 library: Return -errno not print messages
A library should generally return an error value, rather than
printing to stderr a message. procps_loadavg() had a few things
to change:

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

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

This library change will set us up to fix tload.
2022-05-31 21:32:03 +10:00
Craig Small
0ab507fdb1 free: better error message if meminfo not available
When /proc is mounted with subset=pid free just gives the
standard cannot create meminfo structure without any hint why.
free now checks the return value and if it is -ENOENT then it
gives more information about the problem.

References:
 procps-ng/procps#227

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-05-31 21:10:18 +10:00
Craig Small
4a183003a0 library: Cygwin doesnt have /proc/vmstat
Make the vmstat_read_failed() return non-error for Cygwin as
it always will error because /proc/vmstat doesn't exist.

Patch from Achim of the Cygwin project.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-05-31 20:41:30 +10:00
Jim Warner
20859f6fa6 top: the bottom 'window' headings are now translatable
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-31 20:35:44 +10:00
Jim Warner
dedcfa7619 top: remove the 'BOT_MENU_YES' prototype demonstration
Now that a potential use of that bottom 'window' for a
menu has been demonstrated, we'll remove such clutter.

[ after all, the prior commit cautioned against text ]
[ made conditional which might also be translatable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-31 20:35:44 +10:00
Jim Warner
b587d946bf top: don't make translatable text subject to a #define
While it is acceptable to make text usage conditional,
one must never make the text itself conditional. After
all, the translators must be presented with all of the
text so the opportunity to translate it is never lost.

[ one wonders who the idiot was that did this anyway ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-31 20:35:44 +10:00
Jim Warner
daedcb974e top: cleanup of miscellaneous stuff from prior commits
Fix some errors introduced in the commits shown below.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-31 20:35:44 +10:00
Craig Small
e47af25534 library: Cygwin only has 4 cpu numbers
Old library never checked how many matches there were meaning that
both 8-number and 4-number cpu lines would work.
2022-05-26 17:53:43 +10:00
Jim Warner
723b418cd4 top: enable bottom 'window' multi-byte char capability
If the special bottom 'window' routines remain unaware
of potential multi-byte characters, that heading could
be truncated prematurely and unnecessary blank line(s)
added to the reserved rows at the bottom of a display.

So, in both cases, this patch will now account for any
difference between string lengths and display columns.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-26 17:36:29 +10:00
Jim Warner
ef1d82cf18 top: rework bottom 'window' logic to reduce redundancy
This patch attempts to reduce the proliferation of the
bottom window support routines by combining the 'misc'
with 'item' functions. Along the way we can now rename
those two 'pick' functions 'menu' while keeping proper
alphabetic order among all the bottom window routines.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-26 17:36:29 +10:00
Craig Small
6e661d2724 build-sys: Give sensible errors if missing pkg-config
pkg-config is used to find various libraries used by procps.
Unfortunately it, or rather automake, give terrible misleading
error messages if pkg-config is not installed.

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

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

The internet is filled with such wonderful other examples.

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

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-05-25 21:08:50 +10:00
Craig Small
8128641814 build-sys: Use ncursesw by default
The existing build system would only require wide ncurses for
a wide watch and even if the library was there would not link
anything else to it.

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

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

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

In related news, I hate M4sh.

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-05-21 11:06:57 +10:00
Jim Warner
f080820931 library: silence the clang warning for 'uptime' module
Reference(s):
proc/uptime.c:191:9: warning: variable 'uphours' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-20 16:23:20 +10:00
Jim Warner
e99c5abbf3 top: extend shift+tab (back_tab) navigation to console
Really, extend shift+tab navigation to only some linux
consoles (or maybe most consoles). However, there were
some consoles where shift+tab always yields just '\t'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-20 16:23:20 +10:00
Jim Warner
1dd27ba3fc top: apply a special emphasis with some focus elements
Since top now uses string vectors for two items in the
new focus window (cmdline & environ), there is no real
use for that 'separator' specified at toggle time. So,
this commit will find a new use for what is the space.

Henceforth, when a user is navigating using the tab or
backtab keys, should a strv element with focus contain
embedded space(s), it will be emphasized & highlighted
using the current window's message color (capclr_msg).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-20 16:23:19 +10:00
Jim Warner
304c4370bb top: some imbedded literals are now manifest constants
A commit that changes no code but, hopefully, helps to
better document where and how such literals were used.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-20 16:23:19 +10:00
Craig Small
3ee7a4d7f9 docs: Update news for watch equexit
References:
 commit 3ac20bf536
2022-05-18 21:50:14 +10:00
Orhun Parmaksız
3ac20bf536 watch: Add --equexit option
This commit adds a new option called `--equexit` which is the opposite
of `--chgexit`. This option makes it possible to exit when the output
of the given command does not change for the given number of cycles.
A download operation could be given as a use-case since `watch` will
exit when the output does not change anymore, in other words, when
the download is completed.

References:
 procps-ng/procps#232

Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
2022-05-18 11:40:25 +00:00
Craig Small
3f48e8bdfc docs: Minor fix for kill.1 manpage
Merge request 154 brought up the issue of the space before the commar
after sigaction, however the MR included the translated generated
pages.

References:
  procps-ng/procps!154

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-05-18 21:37:26 +10:00
Jim Warner
fc3ba30af6 top: modify 'focus' strv function to display 'n/a' too
This commit just brings that 'bot_focus_strv' function
up to the same standard as the vanilla 'bot_focus_str'
guy. Namely, if there is no cmdline or environ for any
process, that bottom window will now display an 'n/a'.

[ with the nature of those string vectors, it wasn't ]
[ the same simple process found for regular strings. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-18 21:30:56 +10:00
Jim Warner
434e224230 top: extend 'focus' navigation to shift+tab (back_tab)
Some of those bottom windows grow quite large, as with
the firefox environment. If one is navigating the data
using the tab key, it can be very inconvenient when an
element should be reexamined but that focus has moved.

Therefore, this commit will support the 'back_tab' key
which is a standard combination of the shift+tab keys.

Now a user can easily backup up to any missed element,
assuming a terminal emulator honors that terminfo key.

[ a gui emulator typically will honor the 'back_tab' ]
[ terminfo string, whereas a linux console does not. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-18 21:30:56 +10:00
Jim Warner
c00d09edf1 top: be more careful with memcpy length specifications
Using 'mempcpy' was a mistake where plain old 'memcpy'
was appropriate. More importantly, the careless length
specified resulted in a SEGV under some circumstances.

[ namely, it occurred under a multi-threaded top and ]
[ the top program itself as focus + CtrlN 'environ'. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-18 21:30:56 +10:00
Jim Warner
73b4f1134f top: modify 'Ctrl' bottom window 'str' use with 'strv'
After satisfying increased buffer size in the previous
patch, I decided to improve the highlight accuracy for
both the command lines plus the environment variables.

Since they both may contain elements which themselves
include embedded spaces, to accomplish this goal, one
must trade vanilla strings for string vectors instead.

[ at last such library items have now been justified ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-16 20:06:18 +10:00
Jim Warner
da36ff2b8d top: needed 'Ctrl' bottom window fixes were discovered
As it turns out, some of the 'environ' strings are big
enough to overrun the initial buffer sizes. And, while
no real harm was done (other than to silently truncate
the output), this patch will increase the buffer size.

While we're at it. we will normalize a few more buffer
declarations along with correcting a couple typos too.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-16 20:06:18 +10:00
Jim Warner
b8f79a7bb8 doc: man page adjusted for response to keyboard inputs
[ and along the way, those 2 newest namespace fields ]
[ are now mentioned under that same 'X' command part ]
[ this commit already changed for improved response. ]

[ they should have been included in the patch below. ]

Reference(s):
commit 6e78355d4d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-16 20:05:59 +10:00
Jim Warner
3ea1bc779f top: program is now more responsive to keyboard inputs
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-16 20:05:59 +10:00
Jim Warner
381af1af81 doc: detail 'Ctrl' bottom window namespaces plus focus
[ along the way we will restore '^R' to keys summary ]
[ plus correct a leftover reference to 'Ctrl-V' too. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-16 20:05:59 +10:00
Jim Warner
659590b068 top: extend 'Ctrl' bottom window for 'memu' selections
This commit adds a prototype for a potential extension
of that tabbed bottom window capability. It introduces
a 'menu' which then provides for users' selections. It
does not actually do anything meaningful and will only
be enabled with the new #define called 'BOT_PICK_YES'.

[ since it's just a proof of concept, no attempt has ]
[ been made to add the usual NLS translation support ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-05-16 20:05:59 +10:00