Commit Graph

2939 Commits

Author SHA1 Message Date
Craig Small
deeb82411f build-sys: Fix paths for check-lib
Forgot to move the location for test_Itemtables

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-31 17:30:34 +10:00
Craig Small
f5ba25afe6 skill: Update include location too
skill got missed in the main update as its not compiled by
default.
2022-08-29 21:37:40 +10:00
Craig Small
2c3635b687 docs: Update manpages
Change include directory <procps/ -> <libproc2/
Change link instruction -lproc-2 -lproc2
2022-08-29 20:56:43 +10:00
Craig Small
b72eb5c9ea build-sys: Move git-version-gen
git-version-gen was the only file in misc/ moving it to local/
2022-08-29 20:53:01 +10:00
Craig Small
4ec809bc6f nls: Update translations for lib change
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 20:50:53 +10:00
Craig Small
55cc33fc0a misc: Update pc file to new library name 2022-08-29 20:42:45 +10:00
Craig Small
15a0a71406 testsuite: Update the library tests for new location
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 20:40:45 +10:00
Craig Small
1502648ff9 library: Rename to libproc2
The newlib library used to be called libproc-2 but the new
name is preferred.

References:
 https://www.freelists.org/post/procps/Next-for-newlib,3

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 20:38:17 +10:00
Craig Small
47a8676625 build-sys: Relocate lib/
test files in lib go to src/tests
include/ goes to local/
lib/*.c goes to local/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 20:28:03 +10:00
Craig Small
dcce8038be build-sys: Need to add libary includes
The default path didn't add the library includes. A standard
build would work, but a make distcheck would not.
2022-08-29 19:16:49 +10:00
Craig Small
56db0bd32c build-sys: Update tests to new binary locations 2022-08-29 19:13:10 +10:00
Craig Small
3d0871728b build-sys: Relocate library to library/
All the dependent programs needed to have their includes moved too

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 19:02:44 +10:00
Craig Small
406b6d311c misc: Move Documentation to doc
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 18:38:52 +10:00
Craig Small
d78f10cb1e nls: Update translations to new source location
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 18:35:04 +10:00
Craig Small
4e9c4026e6 nls: Minor translation update
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 18:30:50 +10:00
Craig Small
dd60d6d6e8 misc: Move all binaries to src
*.c -> src/
ps/* src/ps/
top/* src/top/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 18:29:28 +10:00
Craig Small
8e889ae682 build-sys: Rearrange the manual pages
All man pages are found in ./man
man-po -> po-man

References:
 https://www.freelists.org/post/procps/Next-for-newlib,3

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 18:07:43 +10:00
Craig Small
5fcf104cba build-sys: Removal of contrib directory
There is nothing we have used here for over a decade

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-08-29 17:46:03 +10:00
Craig Small
86c7eeb70d testsuite: Add test for fatal_proc_unmounted
Adding a check to ensure that fatal_proc_unmounted returns
values for things that do not just sit in /proc/self/stat

References:
 commit 52bd019d8c
2022-08-01 22:23:38 +10:00
Jim Warner
52bd019d8c library: refactor flawed function fatal_proc_unmounted
This commit addresses a potentially disastrous flaw in
that fatal_proc_unmounted() function wherein requested
item(s) might not have been returned to the caller yet
were specified at the time of a 'new' or 'reset' call.

The root cause, uncovered by Craig, was due to the old
library look_up_our_self() support function which only
would populate a proc_t with limited 'stat' file data.

This routine will now act the same as all other <pids>
functions which return a stack or stacks. Whatever was
specified with a 'new' or 'reset' will be returned, if
the passed 'return_self' parameter is other than zero.

[ as is so often the case, when flawed code is fixed ]
[ former complexity can be reduced as a side benefit ]

Reference(s):
https://www.freelists.org/post/procps/issue-245-plus-one,2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-08-01 22:12:47 +10:00
Jim Warner
116ce62304 doc: revert mention of limits for fatal_proc_unmounted
With the next commit the fatal_proc_unmounted function
will be refactored to behave as it always should have.
So, a need for the user 'stat' caution will disappear.

Reference(s):
. original man page change
commit 7d44c94317

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-08-01 22:12:47 +10:00
Jim Warner
be5d03f855 ps: adapted to change of VSIZE_PGS item to VSIZE_BYTES
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-08-01 22:12:47 +10:00
Jim Warner
eb1bc8c273 library: change misnamed VSIZE_PGS item to VSIZE_BYTES
Gosh this particular flaw originated way back in 2015.

[ that was when we burdened a caller with additional ]
[ responsibilities for 'stacks_alloc', 'stacks_fill' ]
[ and 'stacks_dealloc'. damn implementation details. ]

Reference(s):
. Aug, 2015 - introduced<pids> api
commit 7e6a371d8a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-08-01 22:12:47 +10:00
Craig Small
7d44c94317 doc: Mention fatal_proc_unmounted limitations
Discovered this while trying to port programs that use the deleted
libprocps function look_up_our_self() which can be found with the
fatal_proc_unmounted() function.

While procps_pids_new() will allow you to specify any items you
care to think of, a subsequent call to fatal_proc_unmounted()
will only fill in the values found in /proc/self/stat.

Added a caveat to the procps_pids manpage pointing out this
limitation.

References:
 https://salsa.debian.org/xorg-team/app/apitrace/-/blob/debian-unstable/lib/os/os_memory.hpp#L44
 https://gitlab.com/-/snippets/2377884

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-07-27 21:12:10 +10:00
Jim Warner
80e2a7a682 top: eliminate a potential abend when exiting 'A' mode
In that issue cited below, Tyson Nottingham identified
a potential abend which was associated with 'alternate
display mode' plus that troublesome 'mkVIZrow1' macro.
He also offered a perfectly adequate fix for that bug.

I refer to that macro as troublesome since it's now so
widely used and sometimes (by design) causes 'begtask'
to go negative (invalid). And now I found yet one more
place where it should have been used but wasn't ('f').

It's also troublesome as evidenced by some git history
listed below. Heck, there was even a commit addressing
the same symptoms (alternate display mode abend) which
Tyson suffered. Clearly, the current design is flawed.

So, with those two issues in mind, I've refactored the
approach to maintaining a visible task in the 1st row.
Henceforth, a 'mkVIZrow1' macro will be issued in only
two places: once at startup and after most keystrokes.

Such an approach likely results in additional calls to
the 'window_hlp' routine that aren't really necessary.
But, it provides a cleaner design less prone to errors
in the future. Besides, such additional overhead would
only be incurred when interacting with the user. Thus,
new costs are of no concern and will never be noticed.

Reference(s):
. Tyson Nottingham reported problem
https://gitlab.com/procps-ng/procps/-/issues/245
. Jun, 2018 - visible row 1 tasks first addressed
commit 6aedeac667
. Jun, 2018 - adressed edge case, new bugs created
commit 9d59ddc466
. Sep, 2018 - additional edge case addressed
commit 59f02f19c7
. May, 2021 - some abends fixed, new error created
commit 8281ac4f98
. Jun, 2021 - try to prorect against future errors
commit 2ea082b4af
. Sep, 2021 - integrate mkVIZ & 'focused' tasks
commit 69978e3650

Discovered by: Tyson Nottingham
Signed-off-by: Jim Warner <james.warner@comcast.net>
2022-07-27 20:24:54 +10:00
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