]> granicus.if.org Git - procps-ng/log
procps-ng
2 years agobuild-sys: Relocate library to library/
Craig Small [Mon, 29 Aug 2022 09:02:44 +0000 (19:02 +1000)]
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>
2 years agomisc: Move Documentation to doc
Craig Small [Mon, 29 Aug 2022 08:38:52 +0000 (18:38 +1000)]
misc: Move Documentation to doc

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agonls: Update translations to new source location
Craig Small [Mon, 29 Aug 2022 08:35:04 +0000 (18:35 +1000)]
nls: Update translations to new source location

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agonls: Minor translation update
Craig Small [Mon, 29 Aug 2022 08:30:50 +0000 (18:30 +1000)]
nls: Minor translation update

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agomisc: Move all binaries to src
Craig Small [Mon, 29 Aug 2022 08:29:28 +0000 (18:29 +1000)]
misc: Move all binaries to src

*.c -> src/
ps/* src/ps/
top/* src/top/

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agobuild-sys: Rearrange the manual pages
Craig Small [Mon, 29 Aug 2022 08:07:43 +0000 (18:07 +1000)]
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>
2 years agobuild-sys: Removal of contrib directory
Craig Small [Mon, 29 Aug 2022 07:46:03 +0000 (17:46 +1000)]
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>
2 years agotestsuite: Add test for fatal_proc_unmounted
Craig Small [Mon, 1 Aug 2022 12:23:38 +0000 (22:23 +1000)]
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 52bd019d8ca09ecfec34b5020eb7b8d612c315f8

2 years agolibrary: refactor flawed function fatal_proc_unmounted
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agodoc: revert mention of limits for fatal_proc_unmounted
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
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 7d44c94317941c1cd3d41325a0128010fe5d1331

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agops: adapted to change of VSIZE_PGS item to VSIZE_BYTES
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
ps: adapted to change of VSIZE_PGS item to VSIZE_BYTES

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: change misnamed VSIZE_PGS item to VSIZE_BYTES
Jim Warner [Thu, 28 Jul 2022 05:00:00 +0000 (00:00 -0500)]
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 7e6a371d8a36b250a2edddff9f5d059640b8132e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: Mention fatal_proc_unmounted limitations
Craig Small [Wed, 27 Jul 2022 11:12:10 +0000 (21:12 +1000)]
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>
2 years agotop: eliminate a potential abend when exiting 'A' mode
Jim Warner [Tue, 26 Jul 2022 05:00:00 +0000 (00:00 -0500)]
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 6aedeac667267b24ba7f03914eec768d661651ed
. Jun, 2018 - adressed edge case, new bugs created
commit 9d59ddc4661453dc65a8fc81dd75bfea40b7696c
. Sep, 2018 - additional edge case addressed
commit 59f02f19c796cdd83a9ec8751f83e10c42080a44
. May, 2021 - some abends fixed, new error created
commit 8281ac4f98cf04c51cbeb746d214201531d660ec
. Jun, 2021 - try to prorect against future errors
commit 2ea082b4af6f4751548e7583fe7430cd97935318
. Sep, 2021 - integrate mkVIZ & 'focused' tasks
commit 69978e365043f27305e487709474947bb377084d

Discovered by: Tyson Nottingham
Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: make the library API pages a little more readable
Jim Warner [Tue, 26 Jul 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agonls: Update po files
Craig Small [Mon, 18 Jul 2022 10:55:01 +0000 (20:55 +1000)]
nls: Update po files

Updates to cover the "new used" change and the pidwait change

2 years agopgrep: Better warning if pidfd_open not implemented
Craig Small [Mon, 18 Jul 2022 10:51:41 +0000 (20:51 +1000)]
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>
2 years agops: Make STIME entries thread safe
Craig Small [Thu, 30 Jun 2022 11:15:37 +0000 (21:15 +1000)]
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>
2 years agotop: if line editing, account for invisible characters
Jim Warner [Tue, 28 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: adjust the man page alignment for 'Ctrl' commands
Jim Warner [Sun, 26 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: adjust the man page alignment for 'Ctrl' commands

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: afford another level of protection for line input
Jim Warner [Sun, 26 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agodoc: Note new Used behavour
Craig Small [Sat, 25 Jun 2022 01:42:08 +0000 (11:42 +1000)]
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>
2 years agotop: adapt for modification to 'MEMINFO_MEM_USED' item
Jim Warner [Wed, 22 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agolibrary: modify calculation of 'MEMINFO_MEM_USED' item
Jim Warner [Wed, 22 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: adjust some parenthesis for correct '^N' behavior
Jim Warner [Thu, 16 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: make 'n/a' (not applicable) notation translatable
Jim Warner [Thu, 16 Jun 2022 05:00:00 +0000 (00:00 -0500)]
top: make 'n/a' (not applicable) notation translatable

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agoNEWS: acknowledge that utf8 multi-byte character input
Jim Warner [Tue, 14 Jun 2022 05:00:00 +0000 (00:00 -0500)]
NEWS: acknowledge that utf8 multi-byte character input

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: enable processing utf8 multi-byte character input
Jim Warner [Mon, 13 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: provide for visual hint when overtype mode active
Jim Warner [Mon, 13 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: avoid premature forced loss of that bottom window
Jim Warner [Mon, 13 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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 d66c1f39b52d53ec279fc638aa4a6352d7672201

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: acknowledge the top 'message log' display ability
Jim Warner [Thu, 2 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: provides a new user 'message log' display ability
Jim Warner [Thu, 2 Jun 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agolibrary: at unref, close these cached file descriptors
Jim Warner [Thu, 2 Jun 2022 05:00:00 +0000 (00:00 -0500)]
library: at unref, close these cached file descriptors

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: Close filehandle for procps_loadavg
Craig Small [Thu, 2 Jun 2022 06:36:40 +0000 (16:36 +1000)]
library: Close filehandle for procps_loadavg

Previous commit didn't close the filehandle after making the
open non-persistent.

References:
 commit 8fcd14de18b998647ba47f5b35feb1d85e2d2f08

2 years agolibrary: clear rc in procps_loadavg again
Craig Small [Tue, 31 May 2022 12:03:22 +0000 (22:03 +1000)]
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 8fcd14de18b998647ba47f5b35feb1d85e2d2f08

2 years agotload: Report on lack of /proc/loadavg
Craig Small [Tue, 31 May 2022 11:35:40 +0000 (21:35 +1000)]
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 8fcd14de18b998647ba47f5b35feb1d85e2d2f08

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agolibrary: Return -errno not print messages
Craig Small [Tue, 31 May 2022 11:32:03 +0000 (21:32 +1000)]
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.

2 years agofree: better error message if meminfo not available
Craig Small [Tue, 31 May 2022 11:10:18 +0000 (21:10 +1000)]
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>
2 years agolibrary: Cygwin doesnt have /proc/vmstat
Craig Small [Tue, 31 May 2022 10:41:30 +0000 (20:41 +1000)]
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>
2 years agotop: the bottom 'window' headings are now translatable
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
top: the bottom 'window' headings are now translatable

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: remove the 'BOT_MENU_YES' prototype demonstration
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: don't make translatable text subject to a #define
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: cleanup of miscellaneous stuff from prior commits
Jim Warner [Fri, 27 May 2022 05:00:00 +0000 (00:00 -0500)]
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 27f5904edd3772a2f3f66ac62148dee636295933
. Apr, 2022 - added extraneous comma in help text
commit fb32021eeb6f78f01bf455231423a162c9766408

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: Cygwin only has 4 cpu numbers
Craig Small [Thu, 26 May 2022 07:53:43 +0000 (17:53 +1000)]
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.

2 years agotop: enable bottom 'window' multi-byte char capability
Jim Warner [Wed, 25 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: rework bottom 'window' logic to reduce redundancy
Jim Warner [Wed, 25 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agobuild-sys: Give sensible errors if missing pkg-config
Craig Small [Wed, 25 May 2022 11:08:50 +0000 (21:08 +1000)]
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>
2 years agobuild-sys: Use ncursesw by default
Craig Small [Sat, 21 May 2022 01:06:57 +0000 (11:06 +1000)]
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>
2 years agolibrary: silence the clang warning for 'uptime' module
Jim Warner [Wed, 18 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: extend shift+tab (back_tab) navigation to console
Jim Warner [Wed, 18 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: apply a special emphasis with some focus elements
Jim Warner [Wed, 18 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: some imbedded literals are now manifest constants
Jim Warner [Wed, 18 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agodocs: Update news for watch equexit
Craig Small [Wed, 18 May 2022 11:50:14 +0000 (21:50 +1000)]
docs: Update news for watch equexit

References:
 commit 3ac20bf5366b5784d8ee4b1f927e96f4dd164f28

2 years agowatch: Add --equexit option
Orhun Parmaksız [Thu, 31 Mar 2022 19:36:57 +0000 (22:36 +0300)]
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>
2 years agodocs: Minor fix for kill.1 manpage
Craig Small [Wed, 18 May 2022 11:37:26 +0000 (21:37 +1000)]
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>
2 years agotop: modify 'focus' strv function to display 'n/a' too
Jim Warner [Tue, 17 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: extend 'focus' navigation to shift+tab (back_tab)
Jim Warner [Tue, 17 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: be more careful with memcpy length specifications
Jim Warner [Tue, 17 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: modify 'Ctrl' bottom window 'str' use with 'strv'
Jim Warner [Sun, 15 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: needed 'Ctrl' bottom window fixes were discovered
Jim Warner [Sun, 15 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agodoc: man page adjusted for response to keyboard inputs
Jim Warner [Fri, 13 May 2022 05:00:00 +0000 (00:00 -0500)]
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 6e78355d4d1ab011c1d65ebbec9a4408b743a6b3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: program is now more responsive to keyboard inputs
Jim Warner [Fri, 13 May 2022 05:00:00 +0000 (00:00 -0500)]
top: program is now more responsive to keyboard inputs

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: detail 'Ctrl' bottom window namespaces plus focus
Jim Warner [Thu, 12 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: extend 'Ctrl' bottom window for 'memu' selections
Jim Warner [Thu, 12 May 2022 05:00:00 +0000 (00:00 -0500)]
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>
2 years agotop: extend 'Ctrl' bottom window for focus via tab key
Jim Warner [Thu, 12 May 2022 05:00:00 +0000 (00:00 -0500)]
top: extend 'Ctrl' bottom window for focus via tab key

This commit introduces the 'tab' key which can be used
to highlight individual elements in that bottom 'Ctrl'
window. This can really help when reviewing such data.

[ note, normal ongoing monitoring continues unabated ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: expand 'Ctrl' bottom window to display other data
Jim Warner [Thu, 12 May 2022 05:00:00 +0000 (00:00 -0500)]
top: expand 'Ctrl' bottom window to display other data

This commit adds support for displaying the namespaces
in top's separate bottom 'Ctrl' window. Along the way,
the plumbing is now in place to extend this capability
to other data (if we don't run out of '^' keystrokes).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: rename 'Ctrl' bottom window routines and relocate
Jim Warner [Thu, 12 May 2022 05:00:00 +0000 (00:00 -0500)]
top: rename 'Ctrl' bottom window routines and relocate

This patch will just set the stage for the next commit
where we'll be adding the capability to display things
that sometimes may necessitate multiple library items.

In that effort we will be adding several new routines.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agops: Document -P option
Craig Small [Wed, 11 May 2022 07:34:12 +0000 (17:34 +1000)]
ps: Document -P option

The -P option for ps has been in there for decades but neither the
man page nor the help option explained what it did.

Amazing what crops up even now!

References:
 https://unix.stackexchange.com/questions/701422/what-does-p-mean-in-the-context-of-the-ps-command

2 years agodoc: bring the namespaces up to date with linux kernel
Jim Warner [Thu, 5 May 2022 05:00:00 +0000 (00:00 -0500)]
doc: bring the namespaces up to date with linux kernel

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agops: make those namespaces up to date with linux kernel
Jim Warner [Thu, 5 May 2022 05:00:00 +0000 (00:00 -0500)]
ps: make those namespaces up to date with linux kernel

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: bring the namespaces up to date with linux kernel
Jim Warner [Thu, 5 May 2022 05:00:00 +0000 (00:00 -0500)]
top: bring the namespaces up to date with linux kernel

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: bring namespaces up to date with linux kernel
Jim Warner [Thu, 5 May 2022 05:00:00 +0000 (00:00 -0500)]
library: bring namespaces up to date with linux kernel

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: turn off the 'Ctrl' bottom window with 1 more key
Jim Warner [Thu, 5 May 2022 05:00:00 +0000 (00:00 -0500)]
top: turn off the 'Ctrl' bottom window with 1 more key

In that commit shown below, the concept of a corrupted
display was introduced so that 'Ctrl' windows could be
redrawn now that they were made more persistent. Well,
it turns out there is another case where redrawing was
necessary. That is when transitioning between task and
thread modes. So this patch addresses those occasions.

Reference(s):
. May, 2022 - introduced Frames_signal BREAK_screen
commit d66c1f39b52d53ec279fc638aa4a6352d7672201

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: fix a bug from when 'Ctrl' window was made sticky
Jim Warner [Thu, 5 May 2022 05:00:00 +0000 (00:00 -0500)]
top: fix a bug from when 'Ctrl' window was made sticky

In the patch referenced below the bottom 'Ctrl' window
was made to remain until it was dismissed by the user.

As such, it required abandoning a 'Cap_nl_clreos' used
when all the terminal rows had not been drawn. Instead
each line had to be cleared individually until the row
reserved for that 'Ctrl' window area had been reached.

Unfortunately, while a 'Cap_nl_clreos' didn't create a
problem for 'batch' mode, a 'Cap_clr_eol' used instead
yielded an unending loop if those rows were limitless.

So, now we will only clear that area when top isn't in
'batch' mode (which should have always been the case).

Reference(s):
. May, 2022 - bottom window made sticky
commit 0f2a755b0b2754fca79545984e25ec52f4ae4444

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agobuild-sys: Add missing configure flag
Craig Small [Wed, 4 May 2022 07:02:39 +0000 (17:02 +1000)]
build-sys: Add missing configure flag

Missed adding configure.acfor the use ctty commit

References:
 commit b47693c078c256e897baf6b50f3aaf6accb5d35e

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotop: avoid library shame with refactored 'Ctrl' window
Jim Warner [Wed, 4 May 2022 05:00:00 +0000 (00:00 -0500)]
top: avoid library shame with refactored 'Ctrl' window

Well darn it, whoever wrote that new library caught me
with my pants down (again?). Shoot, they were not just
down but somehow missing altogether. Here's the story.

Any item from that library supported by dynamic memory
can only be represented in user's stacks exactly once.

Should any string based enumerator be duplicated among
the items array, for any instance beyond the first the
library will return '[ duplicate ENUM ]' for a result.

That's where I lost my pants. While command lines were
given special handling (and never duplicated) I failed
to turn on CGROUPS, SUPGRPS & ENVIRON when testing the
Ctrl-G, Ctrl-U & Ctrl-N keys. If any of those 3 are on
that's when a Ctrl window sees a 'duplicate' notation.

[ and who runs top with such fields displayed anyway ]

In responding to this oops, the internals were changed
quite dramatically & vastly simplified in the process.

More importantly, the 'duplicate' results are no more.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: cygwin fixes for devname
Craig Small [Tue, 3 May 2022 10:33:44 +0000 (20:33 +1000)]
library: cygwin fixes for devname

Change the default name to cons%d

ctty can be used by other systems not just Cygwin so create a define
separate to cygwin for using the ctty function. The autoconf will need
to be updated to check for these specific systems in future.

Thanks to Achim of the Cygwin project for the patches.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agolibrary: Use standard major minor macros
Craig Small [Tue, 3 May 2022 10:13:49 +0000 (20:13 +1000)]
library: Use standard major minor macros

I'm not sure why you would roll your own macros for major and minor
while the standard includes have these defined. Using our versions
causes two problems:
 - Some systems don't use this format for their minor/major
 - If the kernel proc interface becomes a 64-bit number, like
   dev_t is in the library, then our macro will need to be changed.

autoconf already had the check and as a bonus for anyone that
puts these definitions in sys/mkdev.h it handles that too.

So this is now the standard way of getting a minor/major number out of a
device id. Examining bits/sysmacros.h showed that their defines are
close to what devname.c had, except it can handle 64-bit numbers.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotestsuite: shmget returns an int
Craig Small [Tue, 3 May 2022 09:41:00 +0000 (19:41 +1000)]
testsuite: shmget returns an int

Stops the compilier (correctly) complaining:

lib/test_shm.c: In function ‘main’:
lib/test_shm.c:65:23: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘int’ [-Wformat=]
   65 |     printf("SHMID: %llx\n", shm_id);
      |                    ~~~^     ~~~~~~
      |                       |     |
      |                       |     int
      |                       long long unsigned int

shm_id is an int which is what shmget() returns.

Strangely pmap has always scanned this in as a llx even though the maps
"inode" column is the same number that shmget() returns.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotestsuite shmid can be hex too
Craig Small [Tue, 3 May 2022 09:37:39 +0000 (19:37 +1000)]
testsuite shmid can be hex too

Previously the match for shmid was \d+ but the variable is printed
as a hex number, updated the regex to suit.

Added some changes for pmap test so if the test_shm process fails
we just skip past it.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agotop: turn off the 'Ctrl' bottom window after some keys
Jim Warner [Tue, 3 May 2022 05:00:00 +0000 (00:00 -0500)]
top: turn off the 'Ctrl' bottom window after some keys

To complete the implementation of this new feature, we
must address the problem created by any commands which
offer their own full replacement displays. Should that
'Ctrl' bottom window be active, a return from any such
command leaves that lower portion of a terminal blank.

While we could issue a 'TAGGED_TOSS' macro right after
invoking any of those 4 (currently) affected commands,
it is wrong to make them aware of this 'tagged' stuff.

So, I'll opt for a more generalized solution whereby a
notice regarding a corrupted screen is broadcast. Then
the logic already aware of 'tagging' can deal with it.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: allow sticky 'Ctrl' bottom window code by #define
Jim Warner [Mon, 2 May 2022 05:00:00 +0000 (00:00 -0500)]
top: allow sticky 'Ctrl' bottom window code by #define

After making that new bottom window more persistent, I
decided to offer a build choice for somebody who might
prefer to have the rug pulled out from under him while
reviewing window contents should some target task end.

If 'TAGGED_BRIEF' is defined old behavior is restored.

[ it should be noted, however, that when this define ]
[ is active we'll lose any benefit of onetime update ]
[ for the bottom window. just like with the original ]
[ behavior, it is repainted with every update cycle. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: adapt to the 'Ctrl' bottom window one changed key
Jim Warner [Mon, 2 May 2022 05:00:00 +0000 (00:00 -0500)]
doc: adapt to the 'Ctrl' bottom window one changed key

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: trade just 1 'Ctrl' bottom window key association
Jim Warner [Mon, 2 May 2022 05:00:00 +0000 (00:00 -0500)]
top: trade just 1 'Ctrl' bottom window key association

I grew tired of inadvertently causing a premature exit
from top when all I wanted was to review some process'
environment variables. That 'V' key was just too close
to the 'C' key so the '^V' attempt became one of '^C'.

Well, not any more. Should a user wish to see a task's
environment, it will now require the '^N' combination.

[ it also now places G/U & N/K on a similar diagonal ]

Along the way, lower case Ctrl key combinations on the
help screen were all changed into upper case versions.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: adapt to the 'Ctrl' bottom window sticky behavior
Jim Warner [Mon, 2 May 2022 05:00:00 +0000 (00:00 -0500)]
doc: adapt to the 'Ctrl' bottom window sticky behavior

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: make the new 'Ctrl' bottom window behavior sticky
Jim Warner [Mon, 2 May 2022 05:00:00 +0000 (00:00 -0500)]
top: make the new 'Ctrl' bottom window behavior sticky

After using this new feature for awhile, I encountered
numerous times when that 'Ctrl' window would disappear
as I was studying the contents. This was caused by the
death of the target task but it made me think that the
window could/should persist until dismissed by a user.

Well, now it will persist until that same Ctrl key has
been struck a 2nd time or a different Ctrl key used to
target another process after positioning it on row #1.

So now, instead of that former 'moving target' type of
approach, this window is more of a 'snapshot' in time.

[ even more significant, perhaps, is the fact that a ]
[ Ctrl window will now be drawn exactly 1 time only, ]
[ instead of being repainted after each delay cycle. ]

[ this will remain true no matter how many intervals ]
[ might elapse while its contents were under review. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: eliminate insidious 'LIBPROC_HIDE_KERNEL' bug
Jim Warner [Sun, 1 May 2022 05:00:00 +0000 (00:00 -0500)]
library: eliminate insidious 'LIBPROC_HIDE_KERNEL' bug

When support for the 'LIBPROC_HIDE_KERNEL' environment
variable was introduced, a deficiency was present that
allowed any rejected proc_t (i.e. a kworker thread) to
preserve the strdup'd 'cmd' value. That residual value
would prevent stat2proc or status2proc from updating a
cmd field with the proper program name for some tasks.

This patch just ensures a proc_t is freshened whenever
it has been rejected due to an active PT->hide_kernel.

[ again thanks to Björn for initiating the extension ]

Reference(s):
. original hide_kernel implementation
commit 2a7ec67ac806d91520f59c384684e2332774368b
. original hide_kernel proposal
https://gitlab.com/procps-ng/procps/-/merge_requests/147

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: add a program name to 'Ctrl' bottom window header
Jim Warner [Sun, 1 May 2022 05:00:00 +0000 (00:00 -0500)]
top: add a program name to 'Ctrl' bottom window header

This minor addition to that new 'Ctrl' feature is more
important than it seems. It's responsible for alerting
yours truly to the 'LIBPROC_HIDE_KERNEL' bug addressed
in the very next commit. All this while, program names
for some tasks would be mysteriously replaced with the
kernel 'kworker' names. However, customary clutter for
the top process display tended to obscure such a fact.

[ and, of course, to notice the problem in the first ]
[ place required one to have the command line toggle ]
[ 'off' or perhaps to toggle its state 'on' & 'off'. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agodoc: add variable width data display without scrolling
Jim Warner [Sat, 30 Apr 2022 05:00:00 +0000 (00:00 -0500)]
doc: add variable width data display without scrolling

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: add variable width data display without scrolling
Jim Warner [Sat, 30 Apr 2022 05:00:00 +0000 (00:00 -0500)]
top: add variable width data display without scrolling

There are times when one might want to see some task's
particular variable width data. However, prior to this
commit, the only way was to first turn on a field then
scroll through it via repeated right arrow keystrokes.

[ this also required that field to be displayed last ]

Needless to say, given the potential length of some of
that variable data this could be extremely cumbersome.

Now with this patch, a Ctrl keystroke combination will
create a separate window at the bottom of the terminal
screen where such variable width data is seen in full.

[ the targeted task is the 1st task displayed, which ]
[ is a convention employed in some existing commands ]

[ the targeted data was determined by these Ctrl key ]
[ combinations: CtrlG = ctrl group; CtrlK = cmdline; ]
[ CtrlU = supplementary groups; plus CtrlV = environ ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: eliminate the 'keys_global' redundant definitions
Jim Warner [Fri, 29 Apr 2022 05:00:00 +0000 (00:00 -0500)]
top: eliminate the 'keys_global' redundant definitions

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotestsuite: Add check for shared memory
Craig Small [Tue, 26 Apr 2022 12:04:05 +0000 (22:04 +1000)]
testsuite: Add check for shared memory

Created a test process test_shm that allocates a shared memory
segment and prints the segment ID. pmap testsuite runs pmap to
check that the segment is found.

The value returned by shmget() is the same value that is printed
in the fifth column /proc/<PID>/maps

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agopmap: Don't reopen stdin for reading file
Craig Small [Tue, 26 Apr 2022 11:18:03 +0000 (21:18 +1000)]
pmap: Don't reopen stdin for reading file

pmap uses freopen to read /proc/self/maps. There doesn't
seem to be a good reason to do this and if pmap has its
stdin previously closed then it fails.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2 years agoMerge branch 'time-river/procps-newlib' into newlib
Craig Small [Tue, 26 Apr 2022 10:25:00 +0000 (20:25 +1000)]
Merge branch 'time-river/procps-newlib' into newlib

References:
 procps-ng/procps!155
 procps-ng/procps#236

2 years agosignal: fix suspending ps when receving SIGTERM or SIGHUP
liutie [Tue, 26 Apr 2022 04:11:07 +0000 (12:11 +0800)]
signal: fix suspending ps when receving SIGTERM or SIGHUP

Call trace:
  #0 __lll_lock_wait_private () at
     ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
  #1 0x00007f95c059f9d7 in _L_lock_638 () from /lib64/libc.so.6
  #2 0x00007f95c059f8b6 in _nl_expand_alias
  #3 0x00007f95c059dad8 in _nl_find_domain
  #4 0x00007f95c059d22e in __dcigettext
  #5 0x00007f95c059c05f in __GI___dcgettext
  #6  0x00000000004032b3 in signal_handler (signo=15) at display.c:54
  #7  <signal handler called>
  #8  __memcpy_sse2 () at ../sysdeps/x86_64/memcpy.S:104
  #9  0x00007f95c05d9934 in __GI__IO_getline_info
  #10 0x00007f95c05d99b8 in __GI__IO_getline
  #11 0x00007f95c05e2a5d in __GI_fgets_unlocked
  #12 0x00007f95c059f478 in read_alias_file
  #13 0x00007f95c059f97a in _nl_expand_alias
  #14 0x00007f95c059dad8 in _nl_find_domain
  #15 0x00007f95c059d22e in __dcigettext
  #16 0x00007f95c059c05f in __GI___dcgettext
  #17 0x0000000000403a8d in reset_global () at global.c:410
  #18 0x0000000000402605 in main at display.c:650

The above call trace happens when the ps process is suspending, and the
signal SIGTERM is sent to the ps process at the same time.
Just cancel the SIGTERM and SIGHUP handler when suspending to prevent
the problem.

Signed-off-by: liutie <liutie4@huawei.com>
Signed-off-by: fu.lin <fulin10@huawei.com>
2 years agodoc: added provision for autogroup nice (AGNI) changes
Jim Warner [Sun, 24 Apr 2022 05:00:00 +0000 (00:00 -0500)]
doc: added provision for autogroup nice (AGNI) changes

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: added provision for autogroup nice (AGNI) changes
Jim Warner [Sun, 24 Apr 2022 05:00:00 +0000 (00:00 -0500)]
top: added provision for autogroup nice (AGNI) changes

When autogroups are active programs such as renice and
nice are basically useless because the nice value will
only affect the target task priority relative to other
processes in the same autogroup. So to accomplish what
we thought of as renice, /proc/<pid>/autogroup must be
changed. Altering a single member in an autogroup will
also affect every other member of that same autogroup.

Since top's renice provision ('r') suffers constraints
like those of the stand alone nice/renice programs, we
will now provide a means to manipulate that nice value
found within some process' /proc/<pid>/autogroup file.

[ to alter this file for other user's tasks requires ]
[ root privileges, as does setting a negative value. ]

[ however, unlike that 'r' command, this new command ]
[ allows raising *and* lowering all positive values. ]

Reference(s):
. Aug 2021, autogroups added to librady
commit 631e5d91f3c34374a095b8351235627545617de7
. Aug 2021, autogroups added to top
commit b789b46f84da590a39afd8d74c76c2f5e5436d40

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agotop: the '%CUC' column must be just a little bit wider
Jim Warner [Wed, 20 Apr 2022 05:00:00 +0000 (00:00 -0500)]
top: the '%CUC' column must be just a little bit wider

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agops: that '%CUC' column must be just a little bit wider
Jim Warner [Wed, 20 Apr 2022 05:00:00 +0000 (00:00 -0500)]
ps: that '%CUC' column must be just a little bit wider

Signed-off-by: Jim Warner <james.warner@comcast.net>
2 years agolibrary: fix some 'origin' header comments, <pids> api
Jim Warner [Wed, 20 Apr 2022 05:00:00 +0000 (00:00 -0500)]
library: fix some 'origin' header comments, <pids> api

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