]> granicus.if.org Git - procps-ng/log
procps-ng
3 years agolibrary: fix alignment with new 'io' types, <pids> api
Jim Warner [Sat, 24 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: fix alignment with new 'io' types, <pids> api

The commit referenced below was well done but needed a
small whitespace tweak to preserve existing alignment.

Reference(s):
. io accounting added
commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agomisc: Add NEWS item for previous
Craig Small [Sat, 24 Apr 2021 13:17:35 +0000 (23:17 +1000)]
misc: Add NEWS item for previous

3 years agops: Add IO Accounting fields
Craig Small [Sat, 24 Apr 2021 13:13:38 +0000 (23:13 +1000)]
ps: Add IO Accounting fields

Add the fields for the IO accounting to ps as the library now
has them added from previous commit.

References:
 commit a7afe06e6f1b397b7404fbee724a51f88cc8a59c

3 years agolibrary: adding IO accounting
Craig Small [Sat, 24 Apr 2021 12:38:48 +0000 (22:38 +1000)]
library: adding IO accounting

This is a modification of MR !122 by @renit1609 to fit the new
library.

Problem statement:
The procps library has no PROC_FILLIO flag to
fetch the proc field "/proc/[pid]/io" data
process-wise.
IO Accounting is not included as part of procps.

Requirement:
We have a requirement to fetch process wise
IO utilization which can be used for monitoring.

When looking through the procps library, I see
that IO Accounting (/proc/[pid]/io) is not being
included as part of procps. There is no such
flag like PROC_FILLIO being included in readproc.h .

Solution:
While looking at the implementation done for
other proc fields, I used the spare bits in app code.
I renamed PROC_SPARE_1 as PROC_FILLIO, the spare bit from
PROC_SPARE_* and used it for fetching /proc/[pid]/io
data as part of the procps library similar to other
fields. I moved the PROC_SPARE_* bits each by 1 bit
to retain the spare bits. Meanwhile added the IO fields
in proc_t structure.

References:
 procps-ng/procps!122
 procps-ng/procps#184

3 years agowatch.1: Correct long option for no linewrap.
Craig Small [Sat, 24 Apr 2021 02:01:49 +0000 (12:01 +1000)]
watch.1: Correct long option for no linewrap.

The correct long option for -w is --no-wrap but the man page
said it was --no-linewrap

References:
 procps-ng/procps#203

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agobuild-sys: find split systemd libraries
Christian Hermann [Wed, 14 Apr 2021 07:42:53 +0000 (09:42 +0200)]
build-sys: find split systemd libraries

With 4e7f4237 and 5e73c832, systemd library detection through pkg-config
was changed to unconditionally look for unified libsystemd.

This adds a fallback to match the previous behavior and find the split
libs as well.

References:
 procps-ng/procps!128

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agoescape.c: Fix missing nl_langinfo on certain configs
Issam E. Maghni [Sat, 24 Apr 2021 01:46:48 +0000 (11:46 +1000)]
escape.c: Fix missing nl_langinfo on certain configs

nl_langinfo and CODESET are undefined in a musl system. Instead of
uncondionally including langinfo.h, this change includes include/nls.h
which has the tests and work-arounds for systems that don't have these
features. This is similar to how other programs within procps include
langinfo.h via nls.h

References:
 procps-ng/procps!130

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agoconfigure: Add --disable-w
Issam E. Maghni [Fri, 23 Apr 2021 19:58:36 +0000 (15:58 -0400)]
configure: Add --disable-w

Some systems implement utmp as a stub so it doesn't make sense to have
a non-functioning w.  This change mitigates #193 and !126

References:
 procps-ng/procps!129
 procps-ng/procps!126
 procps-ng/procps#193

3 years agolibrary: fix an insidious bug affecting TICS_ALL_DELTA
Jim Warner [Thu, 22 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: fix an insidious bug affecting TICS_ALL_DELTA

This simple two line code change fixes an intermittent
bug whereby %CPU for parent(s) with collapsed children
could be vastly understated from those displayed under
the current 3.3.17 publicly available top & libprocps.

If one started several top instances in the background
using very a small delay interval (zero?), then if the
shell under which they were running was collapsed, you
would see similar %CPU results for both the libraries.

However, when running a demanding 'make' like a kernel
compile (especially if backed by fast processors and a
SSD), then newlib would generally show only 1/3 to 1/2
of the collapsed %CPU values that appeared for 3.3.17.

Of course, now that the bug has been swatted with this
commit the disparities between those results is easily
explained. Since newly created tasks never contributed
tics during the interval where they were created, only
with many short lived tasks would differences surface.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: lower addr resolution cost for TICS_ALL_DELTA
Jim Warner [Wed, 21 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: lower addr resolution cost for TICS_ALL_DELTA

Rather than run risks of more expensive and repetitive
address resolution, we will establish this local index
for a one time cost and avoid any potential gcc bloat.

[ this commit was made in pursuit of a bug involving ]
[ the distortion of elapsed task tics. but, it turns ]
[ out these changes had nothing to do with that bug. ]
[ however, the patch is being retained as desirable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: respond to library type change for TICS_ALL_DELTA
Jim Warner [Wed, 21 Apr 2021 05:00:00 +0000 (00:00 -0500)]
top: respond to library type change for TICS_ALL_DELTA

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: lessen chance of distortion on TICS_ALL_DELTA
Jim Warner [Wed, 21 Apr 2021 05:00:00 +0000 (00:00 -0500)]
library: lessen chance of distortion on TICS_ALL_DELTA

That old library defined this field as 'unsigned int'.
However, here it was known as a 'signed int'. Thus for
consistency we'll now also treat it as 'unsigned int'.

[ this commit was made in pursuit of a bug involving ]
[ the distortion of elapsed task tics. but, it turns ]
[ out these changes had nothing to do with that bug. ]
[ however, the patch is being retained as desirable. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: fix a couple of spelling errors in new man pages
Jim Warner [Sat, 3 Apr 2021 05:00:00 +0000 (00:00 -0500)]
docs: fix a couple of spelling errors in new man pages

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: eliminate the #define VER_J_RCFILE as superfluous
Jim Warner [Wed, 31 Mar 2021 05:00:00 +0000 (00:00 -0500)]
top: eliminate the #define VER_J_RCFILE as superfluous

With that commit referenced below, which preserved the
'4' and + '!' toggles in the rcfile, this VER_J_RCFILE
macro was made superfluous. But, it was never removed.

Reference(s):
commit b46af6d21399a78f70e349c4476bd5545fbb44ce

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agopkill: Add lt- variants
Craig Small [Mon, 5 Apr 2021 04:40:00 +0000 (14:40 +1000)]
pkill: Add lt- variants

The pgrep code checks to see if the program is run as pkill or pidwait
and changes its behaviour accordingly.  Some older versions of libtool
run the programs as lt-pkill and lt-pidwait which means the tests fail.

We add these two program names to the checks.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agodocs: escape circumflex in sysctl.8
Craig Small [Mon, 29 Mar 2021 11:28:30 +0000 (22:28 +1100)]
docs: escape circumflex in sysctl.8

Groff says special characters should be escaped and some gettext
versions choke on it, so escape the ^

References:
 procps-ng/procps#147

3 years agobuild-sys: Handle zero length diskstats in tests
Craig Small [Mon, 29 Mar 2021 11:23:03 +0000 (22:23 +1100)]
build-sys: Handle zero length diskstats in tests

vmstat -d testsuite will fail if your /proc/diskstats is present
but zero length. While this seems buggy behaviour from lxcfs, its
there and its a simple matter to test for it and skip those tests
if we are run on a zero length /proc/diskstats system.

3 years agodocs: psr ps field is last run processor
Craig Small [Mon, 29 Mar 2021 11:11:27 +0000 (22:11 +1100)]
docs: psr ps field is last run processor

The ps.1 manpage incorrectly stated that psr field showed the
processor the process was assigned to. However if the assignment
has changed but the process has not run, then the field doesn't
change.

Some digging by @srikard showed it wasn't the processor assigned
but the last one it was run on. The man page now correctly
describes psr in that way.

References:
 procps-ng/procps#187

3 years agodocs: Explain sysctl --system better
Craig Small [Mon, 29 Mar 2021 11:07:08 +0000 (22:07 +1100)]
docs: Explain sysctl --system better

The sysctl.8 manpage explained the directory order but not that the
files were then ordered and run in lexiographic order no matter
the directory name.

References:
 procps-ng/procps#200

3 years agotop: replaced one use of fputs(3) with a write(2) call
Shaohua Zhan [Sun, 21 Mar 2021 16:00:00 +0000 (00:00 +0800)]
top: replaced one use of fputs(3) with a write(2) call

This patch is ported from a merge request shown below,
and the following represents the original commit text.

------------------------------------------------------
top: In the bye_bye function, replace fputs with the write interface.

When top calls malloc, if a signal is received, it will
call sig_endpgm to process the signal. In the bye_bye function, if the
-b option is enable, the Batch variable is set, the fputs function
will calls malloc at the same time. The malloc function is not reentrant, so
it will cause the program to crash.

Signed-off-by: Shaohua Zhan <shaohua.zhan@windriver.com>
------------------------------------------------------

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/127

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoslabtop: Check for bad d and o option combination
Craig Small [Thu, 11 Mar 2021 11:10:37 +0000 (22:10 +1100)]
slabtop: Check for bad d and o option combination

If you run slabtop with the -d option and then -o option the
delay gets set to zero and it runs forever. slabtop now checks
for this combination and errors.

Adding a DEJAGNU test also found that none of the slabtop
checks were running so they got added to the list and only the
ones that need /proc/slabinfo (if not readable) are skipped.

References:
 #160

3 years agow: Remove unreachable l option code
Craig Small [Thu, 11 Mar 2021 10:48:14 +0000 (21:48 +1100)]
w: Remove unreachable l option code

@ruihongw quite rightly pointed out we removed the l option
from the man page and getopt but the iunreachable case statement
remained.

References:
 commit 94468ac0b3be07495c1f4eccc9806bb812d93718
 #162

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agofree: Typo fix in error messages
Craig Small [Thu, 11 Mar 2021 10:45:14 +0000 (21:45 +1100)]
free: Typo fix in error messages

doesn't to don't

References:
 #195

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agomisc: needed adaptations for the changes in <pids> api
Jim Warner [Tue, 9 Mar 2021 06:00:00 +0000 (00:00 -0600)]
misc: needed adaptations for the changes in <pids> api

That snowball, which began as a simple removal of some
brackets, now ends with this third patch restoring the
ability to build our project. It was made necessary by
the renaming (and rearranging) of several enumerators.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: fix a few source/origin notations, <pids> api
Jim Warner [Tue, 9 Mar 2021 06:00:00 +0000 (00:00 -0600)]
library: fix a few source/origin notations, <pids> api

After removing brackets from those 'derived' notations
I was surprised to discover that several origin/source
comments were wrong. So this patch fixes those errors.

[ along the way a couple enumerators were renamed to ]
[ better (i hope) reflect what they're representing. ]

[ that, in turn, also required a little rearranging. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: clean 'derived' origins in header, <pids> api
Jim Warner [Tue, 9 Mar 2021 06:00:00 +0000 (00:00 -0600)]
library: clean 'derived' origins in header, <pids> api

None of the other four new api headers use brackets on
derived items. With this patch we normalize the fifth.

[ it makes for a cleaner, less confusing, appearance ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: enabled arbitrarily large numbers in 'scale' guys
Jim Warner [Mon, 8 Mar 2021 12:08:21 +0000 (06:08 -0600)]
top: enabled arbitrarily large numbers in 'scale' guys

While experimenting with a new feature, wherein select
fields display the total upon request, the capacity of
the 'num' passed to some 'scale' guys became an issue.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agops: Add OOM and OOMADJ fields
Craig Small [Fri, 5 Mar 2021 06:22:29 +0000 (17:22 +1100)]
ps: Add OOM and OOMADJ fields

top has had the OOMs and OOMa fields since 2011. Ten years its
probably time that ps had these fields added too.

ps output options have oom and oomadj for OOM Score and OOM Adjustment
respectively.

References:
 procps-ng/procps#198
 commit 367fd902dab64b51ba49709004b5011440e3105a
 https://www.freelists.org/post/procps/PATCH-12-Add-missed-oom-support-to-libproc

3 years agolibrary: tweaked key used in hash table, <meminfo> api
Jim Warner [Tue, 23 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: tweaked key used in hash table, <meminfo> api

This small change was a result of some experimentation
trading our current 'hsearch' hash scheme for 'gperf'.

I discovered that when the ':' character was a part of
each 'gperf' key, that generated search logic was more
complicated and thus slower. But without a ':', it was
a little cleaner/leaner and therefore slightly faster.

Assuming that the same trailing ':' *might* affect the
current 'hsearch' logic, to be safe we will remove it.

[ while the 'gperf' version will slightly outperform ]
[ an 'hsearch', too many ugly implementation details ]
[ were exposed which complicates future maintenance. ]

[ thus, we'll retain our current 'hsearch' approach. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: normalized the 'read_failed' guys across APIs
Jim Warner [Mon, 22 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: normalized the 'read_failed' guys across APIs

This patch will condense some logic in those functions
associated with the file input operations. The changes
will not, for the most part, alter any generated code.

More significantly (though not very) was the change to
two 'strtoul' calls. Since the returned 'endptr' value
isn't exploited, when that parm is set to NULL, we can
save one instruction on each side of such calls (wow).

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agobuild-sys: Fix the uninstall-man target
Craig Small [Wed, 24 Feb 2021 09:58:28 +0000 (20:58 +1100)]
build-sys: Fix the uninstall-man target

If automake doesn't see a dist_man_MANS then there is no
uninstall-man target. This fix uses the main Makefile
targets.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agotests: Fix paths for testsuite
Craig Small [Wed, 24 Feb 2021 09:41:38 +0000 (20:41 +1100)]
tests: Fix paths for testsuite

make distcheck gets confused what is in srcdir and what is in
topdir

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agodocs: tweak two man pages due to renaming of libproc-2
Jim Warner [Sat, 20 Feb 2021 17:11:11 +0000 (11:11 -0600)]
docs: tweak two man pages due to renaming of libproc-2

Reference(s):
commit 9aa09d8862c00a8dc85910d0365332c8c99b59ce

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: eliminate a useless conditional in readproc.h
Jim Warner [Thu, 18 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: eliminate a useless conditional in readproc.h

When #define QUICK_THREADS was introduced, for copying
some task data for a child thread, one proc_t pad byte
was used to mark, then later identify, those children.

Later the QUICK_THREADS was recycled as FALSE_THREADS,
and used for a different purpose, but a conditional in
the header file erroneously remained. Now, it is gone!

Reference(s):
. Jul, 2016 - QUICK_THREADS become FALSE_THREADS
commit c546d9dd4409ee11cd466c99a820a3b5dadfe3f4
. Aug, 2011 - QUICK_THREADS intruduced
commit bb4f08ba297a67a043f7547670aa8623b54c2e67

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: Rename to libproc-2
Craig Small [Sat, 20 Feb 2021 11:30:31 +0000 (22:30 +1100)]
library: Rename to libproc-2

What to call the new library?

Keep using libprocps wouldn't do, its a very different library from
the programs' point of view. It would also mean we could have some
clashes around the packages (two package names, same library name).

The ancient procps used libproc or libproc-a.b.c where a.b.c was the
package version. Kept the revision numbers down (it was always 0.0.0)
but the name of the library changed.

So if we use libproc-2 is there a clash with an ancient procps?
procps v 2.0.0 was around in 1999 so it was 22 years ago, also the
name of the library would have been libproc-2.0.0.so not libproc-2.so
so we're fine with that.

libproc-2 seems to fit, our second major re-work of the procps
library.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agodocs: adjust revision date for our three new man pages
Jim Warner [Tue, 16 Feb 2021 06:00:00 +0000 (00:00 -0600)]
docs: adjust revision date for our three new man pages

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: expand 2 man pages 'Usage' to include VAL macros
Jim Warner [Mon, 15 Feb 2021 06:00:00 +0000 (00:00 -0600)]
docs: expand 2 man pages 'Usage' to include VAL macros

Maybe, the biggest obstacle to successfully exploiting
this new library is after those `stacks' are returned.

Unless a user requests all available `items', there is
always a need to translate an actual enumerator into a
relative position within returned stack(s) of results.

So, this patch attempts to bridge that gap by adding a
brief explanation to the existing discussion in Usage.

[ along the way, 'Usage' & 'Caveats' were refactored ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: tweak logic for /proc not mounted, <pids> api
Jim Warner [Sun, 14 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: tweak logic for /proc not mounted, <pids> api

Since 'procps_uptime' will access the /proc filesystem
the <pids> 'new' guy should should protect against the
possibility /proc isn't mounted when 'boot_seconds' is
established. A zero is better than the negative value.

[ the only distortion would be to PIDS_TIME_ELAPSED. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: normalized 'extents_free_all' use across APIs
Jim Warner [Sat, 13 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: normalized 'extents_free_all' use across APIs

With the way those 'extents_free_all' guys were coded,
there's no real need to check for a NULL this->extents
before calling 'em. That's how <stat> already does it.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agonls: Update man translations for pidwait
Craig Small [Tue, 16 Feb 2021 10:05:05 +0000 (21:05 +1100)]
nls: Update man translations for pidwait

3 years agopidwait: Add missing name change line
Craig Small [Mon, 15 Feb 2021 19:48:51 +0000 (06:48 +1100)]
pidwait: Add missing name change line

Missed one of the lines that changes from pwait to pidwait
in referenced commit.

References:
 commit 9c1a62b6373abe1a88d8cb51a67090950c5097e6

3 years agopidwait: Rename from pwait
Craig Small [Mon, 15 Feb 2021 10:10:06 +0000 (21:10 +1100)]
pidwait: Rename from pwait

pwait is already in at least Debian in a different package

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

3 years agobuild-sys: Ignore temp directory for POTFILES.in
Craig Small [Thu, 28 Jan 2021 11:35:33 +0000 (22:35 +1100)]
build-sys: Ignore temp directory for POTFILES.in

Sometimes the testing sequence would leave a source tree
under procps-ng-(version) which, if update-potfiles was
run, would include these temporary files in the list, causing issues
later.

The script now explicitly ignores those temporary files.

3 years agonls: Update the man po files
Craig Small [Mon, 15 Feb 2021 10:46:53 +0000 (21:46 +1100)]
nls: Update the man po files

Takes into account the procps*.3 manpages and updates them to the
corrected latest versions.

3 years agonls: Update translation files
Craig Small [Mon, 15 Feb 2021 10:37:56 +0000 (21:37 +1100)]
nls: Update translation files

3 years agobuild-sys: Update building of translations
Craig Small [Mon, 15 Feb 2021 10:36:57 +0000 (21:36 +1100)]
build-sys: Update building of translations

newlib was lagging behind oldlib in how the build system created
the translation files.

3 years agolibrary: update those source files for copyright dates
Jim Warner [Fri, 5 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: update those source files for copyright dates

In addition to copyright date, the initial descriptive
line was changed from a generic statement to one which
reflects the specific portion of the proc/ filesystem.

[ such descriptions alternate between 'declarations' ]
[ (h files) & corresponding 'definitions' (c files). ]

Also, a few missing copyright attributions were added.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: update the man page & source file copyright dates
Jim Warner [Thu, 4 Feb 2021 06:00:00 +0000 (00:00 -0600)]
top: update the man page & source file copyright dates

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: bring 2 man pages into agreement regarding sorts
Jim Warner [Wed, 3 Feb 2021 06:00:00 +0000 (00:00 -0600)]
docs: bring 2 man pages into agreement regarding sorts

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: tweak 'other' user/group names for efficiency
Jim Warner [Tue, 2 Feb 2021 06:00:00 +0000 (00:00 -0600)]
library: tweak 'other' user/group names for efficiency

This commit just ensures that the relatively expensive
ID to name conversions aren't performed unless they're
explicitly requested. It also internalizes those flags
that required the PROC_FILLSTATUS flag to also be set.

[ requiring a caller, in our case pids.c, to provide ]
[ two flags when a single field was the objective is ]
[ wrong & represents a future potential toe-stubber. ]

[ moreover, what's worse is that those two flags are ]
[ seemingly unrelated. but, without both, a SEGV can ]
[ can be expected when a result.str pointer is NULL. ]

[ by contrast, in the master branch those fields are ]
[ arrays which, when set to zeroes, produce an empty ]
[ string. So, there is no abend (but no name either) ]
[ when one of those two required flags were omitted. ]

[ and worth noting, in that branch it's not just one ]
[ caller required to observe a two flag requirement. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: vmstat.8 - swap is not virtual memory
Craig Small [Thu, 21 Jan 2021 06:58:48 +0000 (17:58 +1100)]
docs: vmstat.8 - swap is not virtual memory

Chanson Shen rightly pointed out that vmstat swpd stat is
swap memory used not virtual memory used.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agomisc: Update Craig's email
Craig Small [Thu, 21 Jan 2021 06:37:48 +0000 (17:37 +1100)]
misc: Update Craig's email

3 years agodocs: adapt procps_misc.3 for new 'misc.h' header file
Jim Warner [Wed, 20 Jan 2021 06:00:00 +0000 (00:00 -0600)]
docs: adapt procps_misc.3 for new 'misc.h' header file

This commit adapts our man page for a new consolidated
'misc.h' header file. Along the way, some descriptions
were shortened, others lengthened and whitespace added
in an effort to (hopefully) improve readability a bit.

[ the #include subdirectory was also corrected while ]
[ rearranging & grouping functions into 3 categories ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agoall: make buildable again for new 'misc.h' header file
Jim Warner [Tue, 19 Jan 2021 06:00:00 +0000 (00:00 -0600)]
all: make buildable again for new 'misc.h' header file

With the 4 header files removed in the previous patch,
this commit just changes all those obsolete references
to that new consolidated 'misc.h' header file instead.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: combine 4 files into new 'misc.h' header file
Jim Warner [Mon, 18 Jan 2021 06:00:00 +0000 (00:00 -0600)]
library: combine 4 files into new 'misc.h' header file

Prior to this patch, we had four separate header files
dealing with miscellaneous functions. Those four files
were documented in the single man page: procps_misc.3.

Now, we will have just a single header file documented
in a single man page (that is what's called symmetry).

[ and while we're at it, we will shorten that overly ]
[ long struct 'procps_namespaces' name to agree with ]
[ the function naming conventions, e.g. 'procps_ns'. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agodocs: update copyright, revision plus name for 2 pages
Jim Warner [Thu, 14 Jan 2021 06:00:00 +0000 (00:00 -0600)]
docs: update copyright, revision plus name for 2 pages

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: reduce overhead for another 'escape' function
Jim Warner [Wed, 13 Jan 2021 06:00:00 +0000 (00:00 -0600)]
library: reduce overhead for another 'escape' function

The preceding commit made that 'esc_all' function more
efficient by using direct pointer manipulation instead
of an indexed string reference approach within a loop.

This commit applies the same approach to the 'esc_ctl'
function. Now we'll save 12 more iterated instructions
while decreasing the function's code size by 43 bytes.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: improve performance for one 'escape' function
Jim Warner [Tue, 12 Jan 2021 06:00:00 +0000 (00:00 -0600)]
library: improve performance for one 'escape' function

While this patch has some cosmetic whitespace changes,
more importantly it makes that 'esc_all' function more
efficient. By abandoning the indexed loop approach for
a direct pointer manipulation, we will save 9 iterated
machine instructions, for a total of 33 bytes of code.

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agotop: a silly change forcing right margin justification
Jim Warner [Mon, 11 Jan 2021 06:00:00 +0000 (00:00 -0600)]
top: a silly change forcing right margin justification

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: allow setting variable width col scroll (1 vs. 8)
Jim Warner [Wed, 30 Dec 2020 06:00:00 +0000 (00:00 -0600)]
top: allow setting variable width col scroll (1 vs. 8)

The Inspection feature already offered an INSP_SLIDE_1
provision. This patch now offers similar extensions to
variable width column scrolling (assuming SCROLLVAR_NO
isn't defined). Such a provision was useful during the
development of some recent library UTF-8 enhancements.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: relocate the 'fatal_proc_unmounted' function call
Jim Warner [Tue, 29 Dec 2020 06:00:00 +0000 (00:00 -0600)]
top: relocate the 'fatal_proc_unmounted' function call

With the restoration of corrupt utf8 multibyte editing
to the library, it's important to establish the proper
locale before calling that 'fatal_proc_unmounted' guy.

He calls the original 'look_up_our_self' who, in turn,
will invoke 'stat2proc' which then calls 'escape_str'.
Once there, it's too late to effect changes to locale.

[ the result would be lots and lots of '?' displayed ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: refactor 'escape' logic for newlib (2nd time)
Jim Warner [Mon, 28 Dec 2020 06:00:00 +0000 (00:00 -0600)]
library: refactor 'escape' logic for newlib (2nd time)

Much of what was represented in the commit message for
the reference shown below was revisited in this patch.
It also means that the assertion in the last paragraph
of that message will only now be true with LANG unset.

[ and forget all the bullshit about not altering any ]
[ kernel supplied data. sometimes we must to avoid a ]
[ corrupt display due to a string we can not decode. ]

And while this commit still avoids the overhead of the
'mbrtowc', 'wcwidth' 'isprint, & 'iswprint' functions,
we achieve all the benefits with simple table lookups.
Plus such benefits are extended to additional strings.

For example, both PIDS_EXE and PIDS_CMD fields are now
also subject to being 'escaped'. If a program name did
contain multibyte characters, potential truncation may
corrupt it when it's squeezed into a 15/63 byte array.

Now, all future users of this new library only need to
deal with the disparities between string and printable
lengths. Such strings themselves are always printable.

[ the ps program now contains some unnecessary costs ]
[ with the duplicated former 'escape' functions. But ]
[ we retain that copied escape.c code for posterity. ]
[ besides, in a one-shot guy it's of little concern. ]

Note: Proper display of some multibyte strings was not
possible at the linux console. It would seem a concept
of zero length chars (like a 'combining acute accent')
is not recognized. Thus the display becomes corrupted.
But if utf8 decoding is disabled (via LANG=), then all
callers will now see '?', restoring correct alignment.

Reference(s):
. Dec 2020, newlib 'escape' logic refactored
commit a221b9084ae979e6fd073a83e7fbc46c44551f35

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: refactor 'escape' logic for newlib essentials
Jim Warner [Thu, 24 Dec 2020 06:00:00 +0000 (00:00 -0600)]
library: refactor 'escape' logic for newlib essentials

This new library provides callers with pure strings or
string vectors. It is up to those callers to deal with
potential utf8 multibyte characters and any difference
between strlen and the corresponding printable widths.

So, it makes no sense for the library to go to all the
trouble of invoking those rather expensive 'mbrtowc' &
'wcwidth' functions to ultimately yield total 'cells'.

Thus, this patch will eliminate all the code and parms
that are involved with such possible multibyte issues.

[ Along the way we'll lose the ability to substitute ]
[ '?' for an invalid/unprintable multibyte sequence. ]
[ We will, however, replace ctrl chars with the '?'. ]

[ This presents no problem for that ps program since ]
[ it now duplicates all of the original escape code. ]
[ And, we'll no longer be executing that code twice! ]

[ As for the top program, it takes the position that ]
[ it is wrong to alter kernel supplied data. So with ]
[ potential invalid/unprintable stuff, he'll rely on ]
[ terminal emulators to properly handle such issues! ]

[ Besides, even using a proper multibyte string, not ]
[ all terminals generate the proper printable width. ]
[ This is especially true when it comes to an emoji. ]

[ And should callers chose not to be portable to all ]
[ locales by calling setlocale(LC_ALL, ""), they can ]
[ expect to see lots of "?", regardless of what this ]
[ library fixes in a faulty multibyte string anyway. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: added utf8 multibyte support to additional fields
Jim Warner [Wed, 23 Dec 2020 06:00:00 +0000 (00:00 -0600)]
top: added utf8 multibyte support to additional fields

When any process' command line contains multibyte utf8
characters, two separate display problems could arise.

1. If that COMMAND column is not displayed as the very
last field, then field(s) to the right are misaligned.

2. Even when last, should utf8 string length (not that
display length) exceed allowable screen width, it will
nonetheless suffer from improper premature truncation.

Number 1 is less of a concern since the cmdline column
is likely to always be the last field to be displayed,
if only to enable right and left scrolling provisions.

Number 2 is much more likely to occur, especially with
additional fields which might be shown before COMMAND.
Or, forest view child tasks can yield the same effect.

So, this commit will permit the correct utf8 multibyte
display regardless of field position or string length.

And, we'll bring top into line with the ps program for
additional fields potentially subject to utf8 display.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agops: extend utf8 multibyte support to additional fields
Jim Warner [Wed, 23 Dec 2020 06:00:00 +0000 (00:00 -0600)]
ps: extend utf8 multibyte support to additional fields

Form its inception (back in May of 2011), escaped_copy
has always been a flawed function. It does not operate
on 'escaped' strings but instead treats all input as a
regular string incapable of containing utf8 sequences.

As such, it should only be used for strings guaranteed
to NOT embody multibyte characters (like SUPGIDS). For
all other strings, which could contain utf8 stuff, the
correct function should have been that escape_str guy.

So this commit changes nearly every escaped_copy call.

Reference(s):
. May 2011, original escaped_copy (cmdline, cgroup)
commit 7b0fc19e9d28380dc9790615b93bc3653d6d686e

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: fix a potential error relating to 'exe' logic
Jim Warner [Tue, 22 Dec 2020 06:00:00 +0000 (00:00 -0600)]
library: fix a potential error relating to 'exe' logic

After 'errno' management was standardized, a couple of
fields were added to the <pids> api. Only 1 (PIDS_EXE)
involved dynamic memory and, unfortunately, it did not
conform to that expected normalized ENOMEM convention.

Reference(s):
. Jun 2018, added 'exe' to library
commit ad4269f1189d5a7d68765e291bcfa981b6731c25
. Nov 2017, standardized 'errno' management
commit 06be33b43e5ff3f2658e77ef79441ac2e970cfd7

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: extend ITEMTABLE_DEBUG just a tad, <PIDS> api
Jim Warner [Mon, 21 Dec 2020 06:00:00 +0000 (00:00 -0600)]
library: extend ITEMTABLE_DEBUG just a tad, <PIDS> api

Under the above #define this commit now also addresses
2 additional possible toe stubbers involving 'select'.

If some readproc.h constants were uncoupled from their
pids.h enumerators a 'make check-lib' will now detect.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: add pids_item enumerator as comments to task_show
Jim Warner [Sun, 20 Dec 2020 06:00:00 +0000 (00:00 -0600)]
top: add pids_item enumerator as comments to task_show

The Fieldstab uses the full pids_item enumerator names
but also shows top's cryptic relative enumerator names
as comments. So, this commit will mirror that approach
in task_show, adding full pids_item names as comments.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agomisc: just a couple cosmetic changes for comments only
Jim Warner [Sat, 19 Dec 2020 06:00:00 +0000 (00:00 -0600)]
misc: just a couple cosmetic changes for comments only

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agops: Stop crash if using test fields
Craig Small [Tue, 22 Dec 2020 06:50:17 +0000 (17:50 +1100)]
ps: Stop crash if using test fields

I'm not sure if anyone actually uses these things, but if you
selected test fields on the command line ps would crash.

$ ps/pscommand -o _left
Signal 11 (SEGV) caught by pscommand (3.3.11.877-0488).
/home/csmall/Projects/procps/procps/ps/.libs/pscommand:ps/display.c:66: please report this bug
Segmentation fault

Anyway, it doesn't now:
$ ps/pscommand -o pid,_left,_left2,_right,_unlimited 1
    PID LLLLLLLL L2L2L2L2 RRRRRRRRRRR U
      1 tty7     3270/tty4      59:59 [123456789-12345] <defunct>

4 years agopgrep: Remove memory leak
Craig Small [Tue, 22 Dec 2020 05:14:56 +0000 (16:14 +1100)]
pgrep: Remove memory leak

This is part of !118 where @tt.rantala found a memory leak.
The other part of !118 may come later if the performance change
is significant.

References:
 procps-ng/procps!118

4 years agoIf you use echo -e $(put sgr0)"text" - reset color attributes, it turns out the artif...
Alexandr Miasnikov [Fri, 27 Apr 2018 13:27:17 +0000 (13:27 +0000)]
If you use echo -e $(put sgr0)"text" - reset color attributes, it turns out the artifact (Btext

4 years agobuild-sys: Make pwait test dependent on pwait built
Craig Small [Tue, 22 Dec 2020 04:20:30 +0000 (15:20 +1100)]
build-sys: Make pwait test dependent on pwait built

As pwait building is conditional, testsuite should
only run pwait tests if there is a pwait binary.

4 years agomisc: Add pwait to news
Craig Small [Tue, 22 Dec 2020 04:17:58 +0000 (15:17 +1100)]
misc: Add pwait to news

New command, pwait! Waits for another process to finish just like
pgrep finds or pkill kills another process.

References:
 procps-ng/procps!97

4 years agobuild-sys: Change pwait dependency
Craig Small [Tue, 22 Dec 2020 04:16:01 +0000 (15:16 +1100)]
build-sys: Change pwait dependency

master branch uses lib/nsutils, newlib uses lib/signals

References:
 commit c8384e682c1cfb3b2dc797e0f8a3cbaaccf7a3da

4 years agoMerge branch 'awilfox/procps-utmpx-support'
Craig Small [Tue, 22 Dec 2020 03:59:47 +0000 (14:59 +1100)]
Merge branch 'awilfox/procps-utmpx-support'

References:
 procps-ng/procps!67

4 years agoMerge branch 'teknoraver/procps-master'
Craig Small [Tue, 22 Dec 2020 03:32:26 +0000 (14:32 +1100)]
Merge branch 'teknoraver/procps-master'

References:
 procps-ng/procps!83

4 years agopgrep: fix missed change
Craig Small [Tue, 22 Dec 2020 03:25:56 +0000 (14:25 +1100)]
pgrep: fix missed change

I missed one change from the commit in the master branch meaning
pgrep would not compile.

References:
 commit c8384e682c1cfb3b2dc797e0f8a3cbaaccf7a3da

4 years agomisc: Add watch extra colours to NEWS
Craig Small [Tue, 22 Dec 2020 03:13:45 +0000 (14:13 +1100)]
misc: Add watch extra colours to NEWS

4 years agoSupporting bright colors with ncurses
Nipunn Koorapati [Mon, 13 Jul 2020 02:08:26 +0000 (02:08 +0000)]
Supporting bright colors with ncurses

4 years agoAdd comments and limit to standard colors
Nipunn Koorapati [Mon, 13 Jul 2020 00:59:29 +0000 (00:59 +0000)]
Add comments and limit to standard colors

4 years agobugfix - increment endpointer when parsing color_escape_sequence
Nipunn Koorapati [Thu, 2 Jul 2020 07:45:29 +0000 (07:45 +0000)]
bugfix - increment endpointer when parsing color_escape_sequence

4 years agotestsuite: Add pwait tests
Craig Small [Tue, 22 Dec 2020 01:25:44 +0000 (12:25 +1100)]
testsuite: Add pwait tests

They're pretty simple tests but its something.

References:
  commit 09327c2b772fd7bc2762c557855e6a78b6352eb5

4 years agopgrep: add pwait
Alex Xu (Hello71) [Mon, 24 Feb 2020 03:02:59 +0000 (22:02 -0500)]
pgrep: add pwait

4 years agowatch: Support wide char ncurses on mac with enable-watch8bit
Nipunn Koorapati [Mon, 13 Jul 2020 05:08:24 +0000 (22:08 -0700)]
watch: Support wide char ncurses on mac with enable-watch8bit

Fixes #47

4 years agomisc: fix typos in manual pages
Samanta Navarro [Sat, 3 Oct 2020 11:26:22 +0000 (11:26 +0000)]
misc: fix typos in manual pages

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agopkill manpage to document '-e' option
Jan Rybar [Fri, 6 Nov 2020 14:45:56 +0000 (14:45 +0000)]
pkill manpage to document '-e' option

4 years agobuild-sys: Remove refs to old manpage
Craig Small [Tue, 22 Dec 2020 00:27:17 +0000 (11:27 +1100)]
build-sys: Remove refs to old manpage

I removed the old man pages but didn't remove their references in
the Makefile

References:
 commit a978f68c06eb1764d401fa0ffce9fb30cd55f2e4
 commit 770505ded42566b70fd0ee2cade98a317d18ac38
 commit 7246249b8c2683c13515147ff4f9dbb85ba211ae

4 years agopidof: new option to show cmdline-less PIDs (kernel workers), empty input fixed
Jan Rybar [Tue, 22 Dec 2020 00:14:41 +0000 (00:14 +0000)]
pidof: new option to show cmdline-less PIDs (kernel workers), empty input fixed

4 years agoSet TZ to avoid repeated stat("/etc/localtime")
Stephen Brennan [Fri, 20 Nov 2020 00:03:58 +0000 (16:03 -0800)]
Set TZ to avoid repeated stat("/etc/localtime")

With glibc, each time the strftime() function is used (twice per process
in a typical ps -fe run), a stat("/etc/localtime") system call is used
to determine the timezone. Not only does this add extra system call
overhead, but when multiple ps processes are trying to access this
file (or multiple glibc programs using strftime) in parallel, this can
trigger significant lock contention within the OS kernel.

Since ps is not intended to run for long periods of time as a
daemon (during which the system timezone could be altered and PS might
reasonably be expected to adapt its output), there is no benefit to
repeatedly doing this stat(). To stop this behavior, explicitly set the
TZ variable to its default value (:/etc/localtime) whenever it is unset.
glibc will then cache the stat() result.

4 years agodocs: Consistent style across watch.1
ivan tkachenko [Sun, 6 Dec 2020 11:17:23 +0000 (14:17 +0300)]
docs: Consistent style across watch.1

4 years agomisc: Document sysctl change bug
Craig Small [Mon, 21 Dec 2020 23:55:18 +0000 (10:55 +1100)]
misc: Document sysctl change bug

While sysctl did change the order of /run and /etc to match
systemd in the referenced commit, the Debian bug report that
brought it to light was not documented.

References:
 commit 24a1574f0acbe636c98ab13b439c93f7b91de697
 https://bugs.debian.org/950788

4 years agodocs: Merge procps_uptime_* into procps_misc.3
Craig Small [Mon, 21 Dec 2020 01:48:06 +0000 (12:48 +1100)]
docs: Merge procps_uptime_* into procps_misc.3

4 years agodoc: fix typo in procps_misc
Craig Small [Mon, 21 Dec 2020 01:43:00 +0000 (12:43 +1100)]
doc: fix typo in procps_misc

4 years agodocs: Merge procps_ns_* into misc
Craig Small [Mon, 21 Dec 2020 01:41:10 +0000 (12:41 +1100)]
docs: Merge procps_ns_* into misc

4 years agodocs: Merge procps_linux_version into misc
Craig Small [Mon, 21 Dec 2020 01:32:57 +0000 (12:32 +1100)]
docs: Merge procps_linux_version into misc

4 years agomisc: Add test_nsutils to gitignore
Craig Small [Thu, 17 Dec 2020 10:43:10 +0000 (21:43 +1100)]
misc: Add test_nsutils to gitignore

4 years agobuild-sys: a small tweak to the new 'check-lib' target
Jim Warner [Wed, 21 Oct 2020 05:00:00 +0000 (00:00 -0500)]
build-sys: a small tweak to the new 'check-lib' target

So as to not obscure the results from this new target,
we'll redirect that final 'make clean' output to null.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: a tweak to the UNREF_RPTHASH code, <pids> api
Jim Warner [Mon, 19 Oct 2020 05:00:00 +0000 (00:00 -0500)]
library: a tweak to the UNREF_RPTHASH code, <pids> api

If a hash results report is output (via UNREF_RPTHASH)
a portion is devoted to occupied table entries ordered
by depth. There is a possibility that some depths will
not be found among existing occupied table entries and
to avoid any confusion probably should not be printed.

[ to illustrate the potential for confusion prior to ]
[ this patch, force a very small table size (like 8) ]
[ & then trigger the procps_pids_unref() eoj report. ]

So this patch ensures only 'in use' entries are shown.

[ admittedly, all of the remaining logic in the loop ]
[ could/should be subordinate to this new 'if' test, ]
[ but we will keep the change to a minimum. besides, ]
[ there's no harm subtracting/adding a zero numdepth ]
[ especially since the chance of a zero is very low. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agodocs: Add procps_misc.3 manpage
Craig Small [Sat, 24 Oct 2020 07:25:48 +0000 (18:25 +1100)]
docs: Add procps_misc.3 manpage

The last (I think) of the newlib man pages for the new API.