]> granicus.if.org Git - procps-ng/log
procps-ng
4 years agodocs: just a few changes to that new pids man document
Jim Warner [Thu, 25 Jun 2020 05:00:00 +0000 (00:00 -0500)]
docs: just a few changes to that new pids man document

A patch to address the following man doc deficiencies:

. shorten NAME so there's no wrap in an 80x24 terminal
. typo wherein the 'item' parm should have been 'info'
. expand RETURN text for a potential NULL upon success

[ maybe, this might be my last tweak to this man doc ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agoNEWS: updated for those recent utf-8 translation fixes
Jim Warner [Thu, 25 Jun 2020 05:00:00 +0000 (00:00 -0500)]
NEWS: updated for those recent utf-8 translation fixes

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: response to revised numa stuff in that <stat> api
Jim Warner [Wed, 24 Jun 2020 05:00:00 +0000 (00:00 -0500)]
top: response to revised numa stuff in that <stat> api

[ actually, this patch goes a little beyond what was ]
[ strictly required. some messages were expanded for ]
[ clarity and should an inactive node be selected by ]
[ the '3' command, a second '2' no longer is needed. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: changes to some numa stuff in that <stat> api
Jim Warner [Wed, 24 Jun 2020 05:00:00 +0000 (00:00 -0500)]
library: changes to some numa stuff in that <stat> api

Now that we may be getting serious with documentation,
that stat module was revisited with an eye toward user
friendliness. Heck, even this author puzzled over some
of the existing notes and naming conventions employed.

So, this patch will adjust some identifiers and expand
the notes to (hopefully) better serve potential users.

The most significant change was making the STAT_TIC_ID
always valid for numa nodes, even if any are inactive.

Thus the -22222 special STAT_NODE_INVALID constant now
is applied only to STAT_TIC_NUMA_NODE. It will be used
on the cpu summary and reaps with STAT_REAP_CPUS_ONLY.
And it will also mark any numa node that was inactive.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agodocs: tweak both of those newly created man docs a tad
Jim Warner [Tue, 23 Jun 2020 22:29:14 +0000 (17:29 -0500)]
docs: tweak both of those newly created man docs a tad

An important fact was omitted in the DEBUGGING section
for the two newest man documents. Users must utilize a
macro in the header files before verification happens.

So, this commit will sneak in such mention and in that
way reduce future liability if the feature won't work.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agobuild-sys: tweak Makefile.am for two preceding patches
Jim Warner [Mon, 22 Jun 2020 05:00:00 +0000 (00:00 -0500)]
build-sys: tweak Makefile.am for two preceding patches

This commit cleans up some man document files. It also
changes the target install directory from the original
'proc/' to 'procps/' (feels like a more natural name).

[ and, now it agrees with those 2 preceding man docs ]
[ since it is obvious the tail was wagging this dog! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agodocs: replace 'procps_pids' stuff with revised version
Jim Warner [Sun, 21 Jun 2020 05:00:00 +0000 (00:00 -0500)]
docs: replace 'procps_pids' stuff with revised version

The original approach contained a fatal flaw. In order
to use those man pages, users would have been required
to already know how to use the library. Or alternately
one could randomly search each of them while trying to
ascertain which function call satisfies their need and
what exactly was the proper compliment/order required.

So, this revised approach tries to simplify things and
document only what is not apparent in the header file.
Along the way, the following assumptions were germane.

1) It is the kernel folks' job to document /proc files
not to mention fields within those files. And since we
don't yet know what some of those fields represent, we
shouldn't attempt to document any of those we do know.

2) Our header file serves as an essential reference in
successful exploitation of this new library interface.

3) The description represents functions as they appear
in the header itself making them immediately familiar.

4) Armed with our header file users can easily see the
self-documenting enumerators & structures. There isn't
a need to explain them yet again in this man document.

5) Contrary to man guidelines, we shouldn't list error
codes. Simple generic guidance serves everyone better.

The following references represent a history for those
man documents this new version is intended to replace.

Reference(s):
. 04/18/16, create libproc.3 + procps_pids_new.3
commit 4217eddf474debe55a7651757ccce1e86aeb04a5
. 04/19/16, create procps_pids_read_open.3
commit d48c54f6793d5faf44e420df43a75e04372d5945
. 01/05/17, create many procps_pids_... docs
commit 2598e9f2ce39c93ebf55f664454d3bea919ed4e0

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agodocs: update 'first cut' procps.3 with revised version
Jim Warner [Sat, 20 Jun 2020 05:00:00 +0000 (00:00 -0500)]
docs: update 'first cut' procps.3 with revised version

This represents the 'second cut' at providing a shared
man page that supports more than one newlib interface.

In this approach, the following assumptions were made:

1) It is the kernel folks' job to document /proc files
not to mention fields within those files. And since we
don't yet know what some of those fields represent, we
shouldn't attempt to document any of those we do know.

2) Our header files serve as an essential reference in
successful exploitation of the new library interfaces.

3) The description represents functions as they appear
in the header itself making them immediately familiar.

4) Some inconsistencies among the interfaces have been
handled more visually rather than in a narrative form.

5) Armed with our header file users can easily see the
self-documenting enumerators & structures. There isn't
a need to explain them yet again in this man document.

6) Contrary to man guidelines, we shouldn't list error
codes. Simple generic guidance serves everyone better.

Reference(s):
. 05/19/20, procps.3 man page introduced
commit fc69028d374ae933b55b05b0f1418ac6a3da87e2

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agomisc: respond to library rename of structs to 'reaped'
Jim Warner [Fri, 19 Jun 2020 05:00:00 +0000 (00:00 -0500)]
misc: respond to library rename of structs to 'reaped'

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: rename a couple of 'reap' structs to 'reaped'
Jim Warner [Fri, 19 Jun 2020 05:00:00 +0000 (00:00 -0500)]
library: rename a couple of 'reap' structs to 'reaped'

In preparation for a documentation attempt, this patch
renames 'struct reap' to 'struct reaped' in two of our
interfaces. That will bring all the non-pid interfaces
into agreement since the <stat> api already used that.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: provide for zero length character in utf8 support
Jim Warner [Thu, 18 Jun 2020 05:00:00 +0000 (00:00 -0500)]
top: provide for zero length character in utf8 support

This commit is prompted by the preceding change to the
library's escape.c module which, in turn, was prompted
by that issue shown below (with thanks to Konstantin).

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/176

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: correct that 'escape_str_utf8' guy's behavior
Jim Warner [Wed, 17 Jun 2020 13:58:50 +0000 (08:58 -0500)]
library: correct that 'escape_str_utf8' guy's behavior

Thanks to Konstantin for discovering 2 problems in the
issue referenced below. That 15+ year old logic went a
little too far overboard wrestling with a utf8 string.

Henceforth, we will not treat 'x9b' as special. And we
also will handle a 'combining acute accent' correctly.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/176

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: some miscellaneous accumulated tweaks and cleanup
Jim Warner [Mon, 15 Jun 2020 05:00:00 +0000 (00:00 -0500)]
top: some miscellaneous accumulated tweaks and cleanup

I've grown to hate that man document rendering when it
comes to hyphenation. So this patch will eliminate it.

And we'll also eliminate an unnecessary initialization
in that top program code concerned with combined cpus.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agodocs: some manpage fixes
Craig Small [Thu, 4 Jun 2020 12:25:26 +0000 (22:25 +1000)]
docs: some manpage fixes

Some editorial changes so the man pages follow the standards.

References:
 procps#173

4 years agotop: fix a minor startup flaw for the '2 abreast' mode
Jim Warner [Sun, 31 May 2020 05:00:00 +0000 (00:00 -0500)]
top: fix a minor startup flaw for the '2 abreast' mode

This ensures that a single '4' keystroke will reliably
toggle the new 2 abreast mode ON. Depending on whether
an older configuration file existed or whether top was
configured with '--disable-modern-top', keying the '4'
for a second time might otherwise have been necessary.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: help the '#define PRETEND48CPU' be more realistic
Jim Warner [Sat, 30 May 2020 05:00:00 +0000 (00:00 -0500)]
top: help the '#define PRETEND48CPU' be more realistic

An old PRETEND8CPUS #define was reintroduced & changed
to PRETEND48CPU to better exercise the new '4' and '!'
toggles. But, the implementation simply duplicated the
/proc/stat summary line for each cpu. Therefore, every
cpu showed the same graph/detail (depending upon 't').

This patch shows the actual individual cpu information
(duplicated, of course, when total cpus are exceeded).

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: preserved those new '4' and '!' toggles in rcfile
Jim Warner [Fri, 29 May 2020 05:00:00 +0000 (00:00 -0500)]
top: preserved those new '4' and '!' toggles in rcfile

This patch will address Craig's feedback regarding the
original implementation of top's two new toggles. It's
likely other users would have questioned why they were
not saved also, once they discover these new features.

And, since the minimum terminal width was just lowered
to 80 columns, the default for window #1 is also being
changed to show the individual cpu graphs two abreast.

[ assuming no '--disable-modern-top' for ./configure ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172
https://www.freelists.org/post/procps/two-major-changes-to-top,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: warn users if rcfile save prevents older top read
Jim Warner [Fri, 29 May 2020 05:00:00 +0000 (00:00 -0500)]
top: warn users if rcfile save prevents older top read

I'm about to break older top rcfile compatibility when
preserving those two new toggles. And, though this has
happened several times over the years, we never issued
any warnings that such thing was just about to happen.

So, this patch corrects the long standing shortcoming.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: reduce minimum terminal width with 2 abreast mode
Jim Warner [Thu, 28 May 2020 05:00:00 +0000 (00:00 -0500)]
top: reduce minimum terminal width with 2 abreast mode

For the original implementation of the '4' toggle, the
minimum width was set at 165 columns. This was done to
avoid truncations when detailed cpu statistics (versus
graphs) were being displayed. Those can not be scaled.

Upon reflection, it seems more appropriate to give the
user the choice of whether or not to truncate. And, by
reducing that minimum width requirement to 80 columns,
we'll vastly expand potential use of two abreast mode.

[ we'll keep that original as '#define TOG4_NOTRUNC' ]

The patch also updates the man document appropriately.
Along the way, we will trade the potentially confusing
word 'adjacent' for the more natural 'additional' when
detailing the '!' toggle in 4b. Summary-Area-Commands.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172
https://www.freelists.org/post/procps/two-major-changes-to-top

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: address each of the most recent coverity warnings
Jim Warner [Wed, 27 May 2020 05:00:00 +0000 (00:00 -0500)]
top: address each of the most recent coverity warnings

This patch attempts to supress the following warnings:

. MISSING_BREAK, TAINTED_SCALAR plus SIZEOF_MISMATCH .

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agoNEWS: acknowledge those two new top command provisions
Jim Warner [Mon, 25 May 2020 05:00:00 +0000 (00:00 -0500)]
NEWS: acknowledge those two new top command provisions

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: adapt former PRETEND8CPUS #define as PRETEND48CPU
Jim Warner [Sun, 24 May 2020 16:25:01 +0000 (11:25 -0500)]
top: adapt former PRETEND8CPUS #define as PRETEND48CPU

This patch simply allows for better testing of our two
new toggles: '4' (2 abreast) plus '!' (combined cpus).

It had previously been dropped under the newlib branch
since top no longer managed cpus. However, now that we
have those new toggles, it seemed worth the efforts to
once again re-imagine then implement such a provision.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: add '!' toggle for combined cpus display, man doc
Jim Warner [Sat, 23 May 2020 13:51:43 +0000 (08:51 -0500)]
top: add '!' toggle for combined cpus display, man doc

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: add '!' toggle for combined cpus display, program
Jim Warner [Sat, 23 May 2020 13:51:43 +0000 (08:51 -0500)]
top: add '!' toggle for combined cpus display, program

When implementing that earlier '4' toggle, in response
to the issue referenced below, I got to thinking about
those environments with massively parallel processors.

Such environments may not benefit from the '4' toggle.

So, I decided to implement a feature that could enable
use of those '1' and/or '4' toggles no matter how many
active processors top may have ultimately encountered.

With the new '!' toggle, adjacent cpus can be combined
to any degree, represented as a single cpu group/line.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: add '4' toggle for 2 abreast cpu display, man doc
Jim Warner [Fri, 22 May 2020 05:00:00 +0000 (00:00 -0500)]
top: add '4' toggle for 2 abreast cpu display, man doc

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: add '4' toggle for 2 abreast cpu display, program
Jim Warner [Fri, 22 May 2020 05:00:00 +0000 (00:00 -0500)]
top: add '4' toggle for 2 abreast cpu display, program

In the back of my mind, I've always wanted to enable a
two abreast cpu display. Folks with massively parallel
machines must surely have been frustrated with the '1'
toggle when Off (individual cpus in the Summary Area).

So, I'll use that recently raised issue shown below as
a justification for finally implementing this feature.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: eliminate a long standing extraneous comment line
Jim Warner [Thu, 21 May 2020 05:00:00 +0000 (00:00 -0500)]
top: eliminate a long standing extraneous comment line

Wow, hard to believe the extraneous comment line dates
all way back to an introduction of NLS support (2011).

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: misc accumulated cosmetic header file changes
Jim Warner [Wed, 20 May 2020 05:00:00 +0000 (00:00 -0500)]
library: misc accumulated cosmetic header file changes

Well gosh, I only accumulated 1 minor cosmetic change.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agodoc: First cut at new combined API doc
Craig Small [Tue, 19 May 2020 12:43:21 +0000 (22:43 +1000)]
doc: First cut at new combined API doc

Instead of repeating the same thing for each info type, use one
huge man page. Needs more work but lets see how it looks for now.

4 years agodocs: Add namespace man pages
Craig Small [Mon, 18 May 2020 11:42:49 +0000 (21:42 +1000)]
docs: Add namespace man pages

4 years agodocs: Update the uptime man pages
Craig Small [Mon, 18 May 2020 11:10:03 +0000 (21:10 +1000)]
docs: Update the uptime man pages

Three functions in the same manpage but use the so commands
to refer to the main man page.

4 years agopgrep: Allow older than selection
Craig Small [Sun, 17 May 2020 13:00:27 +0000 (23:00 +1000)]
pgrep: Allow older than selection

Re-work merge request !79 of @edneville to permit older than
selection using the new library API.

References:
 procps-ng/procps!79

4 years agowatch: add additional notes about environment
Craig Small [Tue, 12 May 2020 09:30:28 +0000 (19:30 +1000)]
watch: add additional notes about environment

References:
 procps-ng/procps!62
 commit d3e0ff5a0a1c6d123d270b822a828ff52ca8ecaf

4 years agoAdd information on WATCH_INTERVAL env var to watch documentation
Harry Wagstaff [Mon, 23 Apr 2018 10:43:47 +0000 (11:43 +0100)]
Add information on WATCH_INTERVAL env var to watch documentation

4 years agoAdd ability to specify watch interval using environment variable WATCH_INTERVAL
Harry Wagstaff [Mon, 23 Apr 2018 10:34:08 +0000 (11:34 +0100)]
Add ability to specify watch interval using environment variable WATCH_INTERVAL

4 years agovmstat: Add NEWS and revert comment from prev
Craig Small [Tue, 12 May 2020 08:57:26 +0000 (18:57 +1000)]
vmstat: Add NEWS and revert comment from prev

Reverted the translation hint as the fields are used for both
normal and wide modes, so need to fit the smaller of the two.

Added NEWS item

References:
 commit 01c1b2345ee952c28a9995c5766839f43f8e5ac9

4 years agoUse wide columns for r/b too in wide mode
Ivan Skytte Jørgensen [Thu, 8 Jun 2017 12:14:50 +0000 (14:14 +0200)]
Use wide columns for r/b too in wide mode

2 digits are not enough for number of runnable/blocked processes on modern
systems. Changed to 4 digits with given the -w option.

References:
 procps-ng/procps!48

4 years agoFixes small bug in struct proc_t documentation.
Dylan Swiggett [Tue, 29 Nov 2016 22:34:37 +0000 (22:34 +0000)]
Fixes small bug in struct proc_t documentation.

From http://man7.org/linux/man-pages/man5/proc.5.html:

(22) starttime  %llu
                        The time the process started after system boot.  In
                        kernels before Linux 2.6, this value was expressed
                        in jiffies.  Since Linux 2.6, the value is expressed
                        in clock ticks (divide by sysconf(_SC_CLK_TCK)).

4 years agokill: use sigqueue to pass value with the signal.
Arun Chandrasekaran [Fri, 24 Apr 2020 09:22:47 +0000 (19:22 +1000)]
kill: use sigqueue to pass value with the signal.

New -q/--queue option for kill so it will send an integer to the
signalled process. See sigqueue(3) for details.

References:
 https://pubs.opengroup.org/onlinepubs/009695399/functions/sigqueue.html
 procps-ng/procps!32

Signed-off-by: Craig Small <csmall@dropbear.xyz>
4 years agobuild-sys: Enable testing of sigqueue
Craig Small [Tue, 28 Apr 2020 09:40:07 +0000 (19:40 +1000)]
build-sys: Enable testing of sigqueue

The referenced commits enavled both pkill and kill to send an integer to
the killed or signalled process. The test_process now will report on the
integer if sent and the testsuite changes take advantage of this
new feature.

Another process make/destroy set had to be made as using spawn
instead of exec changes both the SID and TTY for the underlying
process, making other tests fail.

References:
 commit 7d55409b82602dac540c011000c9c5abedb5158a
 commit 2b804a532a90a98bccc5255a728da9076a5e4f4f

4 years agopgrep: use sigqueue to pass value with the signal.
Arun Chandrasekaran [Sat, 25 Apr 2020 03:15:06 +0000 (13:15 +1000)]
pgrep: use sigqueue to pass value with the signal.

Based on the command line option, use 'sigqueue'
instead of 'kill' to pass the integer value with
the signal.

References:
 procps-ng/procps!32

Signed-off-by: Craig Small <csmall@dropbear.xyz>
4 years agokill: Adjust documentation for sigqueue
Craig Small [Fri, 24 Apr 2020 09:29:34 +0000 (19:29 +1000)]
kill: Adjust documentation for sigqueue

Added NEWS item
Changed the section for sigqueue as its 3 for me.

4 years agoINSTALL.md: Replace blockquotes with code blocks
Wieland Hoffmann [Fri, 17 Apr 2020 09:50:46 +0000 (09:50 +0000)]
INSTALL.md: Replace blockquotes with code blocks

The previous syntax (`> `) is for blockquotes, which don't keep newlines when
rendered. Codeblocks (` ` at the beginning of the line) do.

4 years agofree: Adjust space to really use 9 chars
Craig Small [Fri, 24 Apr 2020 07:42:58 +0000 (17:42 +1000)]
free: Adjust space to really use 9 chars

@steffhip found that while the translation hint said use 9 characters in
the free headers, it really was only 7.

Currently each line is constructed with the following (in non wide format):
Header + 6 Columns.  The header takes 7 characters and each column is 11
characters wide and prefixed with one space. Thus we have
7 + (1 + 11) * 6 = 79 characters for each line

By dropping the leading space for the first column after the header -the
header is already terminated by a colon- one could indeed provide the needed
9 letters for the header and thus have 9 + 11 * 1 + (1 + 11) * 5 = 80 Chars
per line which would fit into one line.

4 years agoFix user and group name to number conversion for uid/gid above 2^31.
Todd Lewis [Mon, 29 Oct 2018 18:33:48 +0000 (18:33 +0000)]
Fix user and group name to number conversion for uid/gid above 2^31.

4 years agotop: updated man page and copyright dates to year 2020
Jim Warner [Wed, 15 Apr 2020 05:00:00 +0000 (00:00 -0500)]
top: updated man page and copyright dates to year 2020

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: adapted to the latest lxc conventions (again)
Jim Warner [Tue, 14 Apr 2020 05:00:00 +0000 (00:00 -0500)]
library: adapted to the latest lxc conventions (again)

Well, shit! With release 4.0 on March 25th the lxc/lxd
folks have stuck it to us once again. They changed the
cgroup lxc prefix used to identify the container name.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agoNEWS: Add item for previous entry
Craig Small [Fri, 10 Apr 2020 04:47:32 +0000 (14:47 +1000)]
NEWS: Add item for previous entry

Added NEWS item for pidof show worker threads patch

References:
 commit 9c3296bae97a6862d716b2a74f0ef3b76b061d7c

4 years agopidof: show worker threads
Jan Rybar [Tue, 7 Apr 2020 11:41:48 +0000 (13:41 +0200)]
pidof: show worker threads

Reimplementation of pidof for procps toolset contains sort of deactivated code and does not return results for processes without task.cmdline entry (usually kernel worker threads). Old pidof and pgrep do that in comparison. Despite all perks provided by using pgrep instead, pidof should show those workers again.

4 years agoNEWS: fix top alpha order, add 'e' command line switch
Jim Warner [Sun, 29 Mar 2020 05:00:00 +0000 (00:00 -0500)]
NEWS: fix top alpha order, add 'e' command line switch

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: for symmetry with 'E' add 'e' command line switch
Jim Warner [Sun, 29 Mar 2020 05:00:00 +0000 (00:00 -0500)]
top: for symmetry with 'E' add 'e' command line switch

Several years after the 'e' & 'E' interactive commands
were introduce to affect memory scaling, an 'E' switch
was added. This was after discovering a dropped Redhat
patch which provided a unique 'M' command line switch.

If only for symmetry it makes sense to offer a similar
command switch ('e') for the Task Area memory scaling.

As was true with 'E', top's help text will show 'e' as
if it were a switch without arguments in order to keep
help text displayed without wrap in an 80x24 terminal.
The man page, however, will show all of the arguments.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/165
. 03/2017, added 'E' command line switch
commit b2bd65407a2b0c3eb88bbeb05c1d8682a2bfd958
. 12/2012, added 'e' interactive command
commit 21e550bc080eb30f503b2ca6fe4e9cb12b8a1616
. 12/2012, added 'E' interactive command
commit bc46f67f9a63c9f43c9a697b3bfa85abf721c5da

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agops: eliminated inadvertent trailing double semi-colons
Jim Warner [Wed, 11 Mar 2020 05:00:00 +0000 (00:00 -0500)]
ps: eliminated inadvertent trailing double semi-colons

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: eliminate inadvertent trailing double semi-colons
Jim Warner [Wed, 11 Mar 2020 05:00:00 +0000 (00:00 -0500)]
top: eliminate inadvertent trailing double semi-colons

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agoNEWS: synchronise the entries
Craig Small [Tue, 7 Apr 2020 09:40:35 +0000 (19:40 +1000)]
NEWS: synchronise the entries

4 years agodocs: Mention stime in ps.1
Craig Small [Tue, 7 Apr 2020 09:35:27 +0000 (19:35 +1000)]
docs: Mention stime in ps.1

References:
 procps-ng/procps#164

4 years agosysctl: config directory order
Craig Small [Thu, 27 Feb 2020 10:56:13 +0000 (21:56 +1100)]
sysctl: config directory order

Matches the systemd directory order (/run is after /etc) and
document what directories are used better.

4 years agotop: restore configuration file backward compatibility
Jim Warner [Sat, 15 Feb 2020 06:00:00 +0000 (00:00 -0600)]
top: restore configuration file backward compatibility

The Debian bug referenced below has nothing to do with
locales. In fact, top was made locale independent back
in release 3.3.13 (April, 2018). However, that bug did
reveal some misplaced logic which this patch corrects.

Prompted by the Qualys audit, all rcfile field strings
were checked for potential duplicates which could only
have resulted from some user's manual/malicious edits.

Unfortunately, that code was executed before top had a
chance to enforce the proper/maximum string length (in
the event an extremely old rcfile had just been read).
This created some potential string overrun references.

In top's original 3.3.15 implementation, the potential
overrun extended for 15 characters. That is the number
of field characters added with 3.3.9 (December, 2013).
But, since strchr() was used, no error exit was taken.

In the revised 3.3.16 implementation, the strchr() was
replaced with '&w->rc.fieldscur[n]'. This held overrun
to a single position while producing an error message.

So, this commit just moves that logic to a point where
fieldscur is guaranteed to be longer than EU_MAXPFLGS.

Reference(s):
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951335
. revised 3.3.16 validation logic
commit 775223a8174cdede123199a67372dc207a2dbdc2
. original 3.3.15 validation logic
commit 085351a0ee9e7abcaca499dbc1d6444cfa9c9da9

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: restore one line of code to sig_endpgm() function
Jim Warner [Wed, 22 Jan 2020 06:00:00 +0000 (00:00 -0600)]
top: restore one line of code to sig_endpgm() function

When that potential abend at program end was addressed
in the patch shown below, one line of code was removed
in error. That line served to suppress some end-of-job
reports should ATEOJ_RPTSTD or ATEOJ_RPTHSH be active.

So, this patch restores that previously deleted logic.

Reference(s):
. potential SEGV fix, newlib branch
commit 90c22e64ffc52e01ea2c9b81680d4b4a37f2d8c4

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agops: for abnormal end allow core dumps (fix qualys bug)
Jim Warner [Sat, 4 Jan 2020 06:00:00 +0000 (00:00 -0600)]
ps: for abnormal end allow core dumps (fix qualys bug)

A Qualys audit patch, represented in the commit below,
added the _exit() call to our abnormal signal handler.
Unfortunately, that disabled the associated core dump.

This patch restores expected behavior of those signals
whose default produces a core dump file + termination.

Reference(s):
commit 7bd4f0b6d7e058197ccf4234f2a0bcc17550d0a6

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: at abnormal end allow core dumps (fix qualys bug)
Jim Warner [Sat, 4 Jan 2020 06:00:00 +0000 (00:00 -0600)]
top: at abnormal end allow core dumps (fix qualys bug)

A Qualys audit patch, represented in the commit below,
added the _exit() call to our abnormal signal handler.
Unfortunately, that disabled the associated core dump.

This patch restores expected behavior of those signals
whose default produces a core dump file + termination.

Reference(s):
commit e1f419737f01618181686281ae98347e03163e56

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: allow negative system DELTA stats, <STAT> api
Jim Warner [Fri, 13 Dec 2019 05:00:00 +0000 (00:00 -0500)]
library: allow negative system DELTA stats, <STAT> api

All TIC delta fields are checked for possible negative
results and set to zero when found. This is done so as
to protect against potential anomalies which depend on
kernel version and/or toggling cpus offline or online.

[ it's probably unnecessary with the latest kernels, ]
[ except for iowait. documentation suggests it might ]
[ decrease which would then create a negative delta. ]

The same approach is employed for most of the 'system'
deltas (ctxt, intr & procs_created). However, with two
of the fields (procs_blocked & procs_running) negative
results were allowed. But it now seems such a division
is unwise so this patch will allow all to go negative.

[ rather than force any 'system' delta value to show ]
[ what's logical, we'll now let all reflect reality. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: strictly cosmetic change involving whitespace
Jim Warner [Thu, 12 Dec 2019 05:00:00 +0000 (00:00 -0500)]
library: strictly cosmetic change involving whitespace

This patch just standardizes/normalizes the whitespace
employed within a couple of nearly identical #defines.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: reposition some data due to a translation comment
Jim Warner [Wed, 11 Dec 2019 05:00:00 +0000 (00:00 -0500)]
top: reposition some data due to a translation comment

In a translator hint, under a caution, a reference was
made to the "next three items". Unfortunately however,
there was one intervening 'item' to which that caution
did not apply. This commit just relocates that 'item'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agopgrep: check sanity of SC_ARG_MAX
Craig Small [Sun, 5 Jan 2020 04:19:41 +0000 (15:19 +1100)]
pgrep: check sanity of SC_ARG_MAX

A kernel change means we cannot trust what sysconf(SC_ARG_MAX)
returns. We clamp it so its more than 4096 and less than 128*1024
which is what findutils does.

References:
 procps-ng/procps#152
 https://git.savannah.gnu.org/cgit/findutils.git/tree/lib/buildcmd.c#n535
 https://lwn.net/Articles/727862/
 commit bb96fc42956c9ed926a1b958ab715f8b4a663dec

5 years agotop: update copyright notations & fix a man page error
Jim Warner [Sun, 13 Oct 2019 05:00:00 +0000 (00:00 -0500)]
top: update copyright notations & fix a man page error

Beyond the copyrights, the single oops in the man page
was introduced in the commit which is referenced below
dealing with some cleanup following that Qualys audit.

Reference(s):
. man page error introduced
commit 4550e601441bd9e9e4617db4736b4504e90d424d

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: whack insidious bug surrounding auto-sized fields
Jim Warner [Sat, 12 Oct 2019 05:00:00 +0000 (00:00 -0500)]
top: whack insidious bug surrounding auto-sized fields

This patch will eliminate a bug which is unique to our
newlib branch. It's extremely rare and only happens if
a search ('L'/'&') is initiated during the period when
fields are currently being auto-sized (AUTOX_MODE on).

This bug surfaces as either all zero results for tasks
displayed or a segmentation fault, depending upon what
fields were activated. It is caused by the timing of a
call to the <pids> 'reset' function. When called after
a task refresh, but before do_key(), this bug appears.

So this patch just ensures that 'reset' will be called
after do_key() & before the tasks have been refreshed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: removed that 'calloc/free' cruft where doable
Jim Warner [Mon, 30 Sep 2019 05:00:00 +0000 (00:00 -0500)]
library: removed that 'calloc/free' cruft where doable

Under newlib, the only caller of the readproc routines
is that pids module. And in every case, the address of
some static proc_t structure has always been provided.

As a result, there is no need for the logic supporting
calloc() for a possible NULL pointer which was present
in both of those readproc() and readeither() routines.

Additionally, that pids module takes ownership of most
dynamically acquired 'str' plus 'strv' memory whenever
assigning to a results structure. So, henceforth under
the free_acquired() guy we will only free those string
fields which might exist when not explicitly selected.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: removed that 'simple_readtask' unused pointer
Jim Warner [Sun, 29 Sep 2019 05:00:00 +0000 (00:00 -0500)]
library: removed that 'simple_readtask' unused pointer

This patch just eliminates a parameter present for the
simple_readtask() function which is not needed nor has
it ever actually been used. It will make calls to that
function (via taskreader ptr) slightly more efficient.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: removed that 'did_fake' flag from the PROCTAB
Jim Warner [Sat, 28 Sep 2019 05:00:00 +0000 (00:00 -0500)]
library: removed that 'did_fake' flag from the PROCTAB

When some cleanup was performed on the readproc module
in the commit shown below, some residual code involved
with the 'did_fake' flag remained. Since such logic no
longer served any real need, this patch will whack it.

Reference(s):
. cleanup of readproc functions
commit 887bb51016253e82ae26fe9d78bc7a5dfbe2ef85

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: removed that 'SIGNAL_STRING' conditional code
Jim Warner [Fri, 27 Sep 2019 05:00:00 +0000 (00:00 -0500)]
library: removed that 'SIGNAL_STRING' conditional code

No libprocps user expects signal values to be returned
as 'long long' quantities. More importantly the <PIDS>
api only returns a 'str' result for signal categories.

So this patch eliminates all the conditional code that
depends on the absence of the #define 'SIGNAL_STRING'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: correct one reference typo in that <PIDS> api
Jim Warner [Thu, 26 Sep 2019 05:00:00 +0000 (00:00 -0500)]
library: correct one reference typo in that <PIDS> api

This patch will just correct an oops introduced in the
commit shown below. Thank goodness both 'str' & 'strv'
occupy the same storage location in that result union.

Reference(s):
. standardize 'errno' management
commit 06be33b43e5ff3f2658e77ef79441ac2e970cfd7

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agoNEWS: update/catch up with the 'master' branch version
Jim Warner [Fri, 16 Aug 2019 05:00:00 +0000 (00:00 -0500)]
NEWS: update/catch up with the 'master' branch version

With the two preceding 'catch up' patches, this newlib
NEWS can now be made identical to that master version.

[ it's assumed any releases prior to 3.3.15 have all ]
[ been represented under newlib (where appropriate). ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agodocs: use correct units in free.1 _________ (catch up)
Jim Warner [Thu, 15 Aug 2019 05:00:00 +0000 (00:00 -0500)]
docs: use correct units in free.1 _________ (catch up)

Reference(s):
. origina master branch commit, 5/31/18
commit c51b329a32275eed7c3abb716d482fe9d2a1ea44

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agops: increase command name length to 64 ____ (catch up)
Jim Warner [Thu, 15 Aug 2019 05:00:00 +0000 (00:00 -0500)]
ps: increase command name length to 64 ____ (catch up)

Reference(s):
. orginal master branch commit, 5/19/18
commit 14005a371e5c14289e96a4927ffd1a827d3c9d85

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: parallel the master branch pids monitoring change
Jim Warner [Sat, 10 Aug 2019 00:00:00 +0000 (00:00 +0000)]
top: parallel the master branch pids monitoring change

This commit will just parallel a pending master branch
merge request referenced below. Note, however, that it
is not really needed in this newlib branch because the
procps_pids_select() function itself provides a 'zero'
delimiter with every caller's designated list of pids.

[ since it's required under the master branch, we're ]
[ repeating it here just for documentation purposes. ]

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

Originally-by: Yoann Lecuyer <yoann.lecuyer@gmail.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: avoid a potential SEGV during program termination
Jim Warner [Tue, 6 Aug 2019 05:00:00 +0000 (00:00 -0500)]
top: avoid a potential SEGV during program termination

The backtrace shown in the bug report referenced below
illustrates a 'normal' program termination interrupted
with some signal, ultimately then causing a top crash.

So this commit just rearranges a little code such that
all signals will be blocked during that rather lengthy
end of program processing regardless of how initiated.

[ in that report, ignore the assertion regarding the ]
[ '-n' option. it obviously was not '1' since do_key ]
[ had been called, which otherwise wouldn't be true. ]

[ and when it is '1' the -d option would be ignored. ]

Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=1737552

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: tweak logic associated with keyboard translations
Jim Warner [Sat, 3 Aug 2019 05:00:00 +0000 (00:00 -0500)]
top: tweak logic associated with keyboard translations

This commit most significant change is the elimination
of the kbd_ENTER entry from that tinfo_tab in iokey().

That entry was a useless artifact left from the commit
which is shown below. It makes no sense to 'translate'
a keystroke into something it already was (i.e. '\n').

The remaining changes just reorder those table entries
for a progression consistent with vim keys: h,j,k & l.

Reference(s):
. fix 'iokey()' flaw preventing proper translations
commit c3323bdb687076f8e4800e7130f863ebec0a18fb

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotestsuite: pgrep: Provide test for matching a more than 4k command line; beware as...
Clay Baenziger [Sat, 3 Aug 2019 09:58:18 +0000 (05:58 -0400)]
testsuite: pgrep: Provide test for matching a more than 4k command line; beware as TCL does not seem to match on strings >4k

5 years agopgrep: Use POSIX _SC_ARG_MAX for maximum full command line length
Craig Small [Sat, 21 Sep 2019 06:58:30 +0000 (16:58 +1000)]
pgrep: Use POSIX _SC_ARG_MAX for maximum full command line length

Modified for newlib but based upon patch in master by
Clay Baenziger <cwb@clayb.net>

References:
    commit f9e56d3c667513d96b798340f7b7c1b40096f084
    procps-ng/procps!85

5 years agopidof: Fix separator option
Craig Small [Sat, 21 Sep 2019 06:17:05 +0000 (16:17 +1000)]
pidof: Fix separator option

Short separator option used 's' instead of 'S' which
meant it pidof would use the single-shot option when you
meant separator.

Added alias for -S using -d to give some sysvinit pidof
compatibility.

References:
    commit 73492b182dc60c1605d1b0d62de651fad97807af
    procps-ng/procps#141

5 years agowatch: fix unsetting of COLOR flag
Craig Small [Sat, 21 Sep 2019 06:03:28 +0000 (16:03 +1000)]
watch: fix unsetting of COLOR flag

watch used to check if COLOR was required, check if color was
possible then.. set the flag again.

It should have been cleared after failing to get colors out of
ncurses.

References:
 procps-ng/procps#143

5 years agosysctl: ignore errors from lines starting with -
Craig Small [Sat, 21 Sep 2019 05:50:53 +0000 (15:50 +1000)]
sysctl: ignore errors from lines starting with -

The systemd sysctl ignores errors from preload files that start
with a hyphen.  This change brings the procps sysctl into line with
their change.

References:
    procps-ng/procps#138
    https://github.com/systemd/systemd/pull/13191
    https://github.com/systemd/systemd/pull/13141

5 years agotop: standardize PgUp/PgDn management within task area
Jim Warner [Sat, 29 Jun 2019 05:00:00 +0000 (00:00 -0500)]
top: standardize PgUp/PgDn management within task area

This commit standardizes the behavior of the PgUp/PgDn
keys when on the main top display. With PgDn, the last
process will become the first process. With PgUp, that
first task will now appear as the last task displayed.

[ this also eliminates some quirks that were evident ]
[ when paging at or near the end of the process list ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: attempt to provide missing xterm vim keys support
Jim Warner [Mon, 24 Jun 2019 05:00:00 +0000 (00:00 -0500)]
top: attempt to provide missing xterm vim keys support

A recent issue (and merge request) reminded me of gaps
in top's alternate 'vim' navigation keys support. Some
xterm emulators do not pass the customary strings when
keys were used with the <Ctrl> and/or <Alt> modifiers.

While it was a known problem, this issue/merge request
prompted research into the root cause. As it turns out
the problem is traceable to an X resource known by the
name 'eightBitInput'. When 'true' (the default), a key
pressed in combination with <Alt> will not be preceded
by the <Esc> character. Rather, a single character was
presented (modified via an 'eightBitMeta' X resource).

The following approaches would eliminate this problem:

. start xterm thus: xterm -xrm '*eightBitInput: false'

. use: ~/.Xresources with 'Xterm*eightBitInput: false'

. build xterm with 'configure --enable-meta-sends-esc'
( apparently used for CentOS, Fedora, openSUSE, etc. )

. enable xterm's menu via 'configure --enable-toolbar'
( so the user can set the 'Meta Sends Escape' option )

Of course, none of the above steps is desirable from a
user's perspective. So, this patch will add additional
entries to the iokey function's tinfo_tab to represent
strings passed when the <Alt> key does not send <Esc>.

[ hopefully they'll be the same across all platforms ]

Lastly, this patch will also eliminate those redundant
<Atl> + '\', '/', '<' & '>' provisions, which now seem
like overkill and suffer from that same 'eightBitMeta'
xterm problem. And we might as well say goodbye to the
4 '<Alt> + arrow key' table entries (which do not seem
to currently work with any emulator which I can find).

[ what in the world was I thinking way back in 2011? ]

Reference(s):
. issue
https://gitlab.com/procps-ng/procps/issues/135
. merge request
https://gitlab.com/procps-ng/procps/merge_requests/84

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: add a 'CPU_ZEROTICS' equivalent to <STAT> api
Jim Warner [Mon, 3 Jun 2019 05:00:00 +0000 (00:00 -0500)]
library: add a 'CPU_ZEROTICS' equivalent to <STAT> api

This patch just implements an equivalent to the master
branch 'CPU_ZEROTICS' provision. However, the original
impetus for that earlier implementation was ultimately
attributed to a likely kernel anomaly since corrected.

As a result, in this newlib implementation we take the
opposite approach to the default behavior. There is no
adjustment to TIC_SUM_DELTA values if fewer ticks than
expected are recorded, unless the define is activated.

The commit shown below explains why the 'CPU_ZEROTICS'
define was retained in spite of the fix to the kernel.

Reference(s):
. issue referencing CPU_ZEROTICS
https://gitlab.com/procps-ng/procps/issues/132
. master branch CPU_ZEROTICS summary
commit ee3ed4b45edd66c6e0455d3fab08a48e7ea83030
. lengthy thread leading to CPU_ZEROTICS
https://www.freelists.org/post/procps/CStates-handling-new-switch

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: minimize the use of 'cleanup_stacks' routines
Jim Warner [Wed, 22 May 2019 05:00:00 +0000 (00:00 -0500)]
library: minimize the use of 'cleanup_stacks' routines

Some parts of our newlib implementation are the result
of functions which have been propagated from module to
module. In particular, those 'cleanup_stacks' routines
are all similar & likely originated in the <pids> api.

In that interface there was a need to free dynamically
acquired memory before the result structure was reused
to satisfy subsequent 'get', 'select' or 'reap' calls.
This, in turn, led to a concept of 'dirty' stacks with
the need to call one of two 'cleanup_stack' functions.

None of the remaining interfaces deal with such memory
yet they each had their own 'cleanup_stack' functions.
Those functions were responsible for resetting each of
the result unions to zero, excluding any 'noop' items.

The bottom line is that for all interfaces, repetitive
calls would require iterating through the stack(s) two
separate times: once to 'cleanup' another to 'assign'.

With this commit we will reduce iterations to just the
'assign' routine. A reset to zero will be accomplished
in the 'extra' item set routine (which is the only one
actually requiring any reset). All other items will be
reinitialized automatically by a new current set value
or upon reallocation when an items compliment changes.

In the <pids> interface, any freeing of dynamic memory
could have been accomplished by adding that 'freefunc'
check to the 'assign' function. However, that requires
an Item_table test with every item. Instead, we'll now
satisfy such needs as the very first step in those set
functions responsible for dynamically acquired memory.

[ the <pids> api retains 2 'cleanup_stack' functions ]
[ to accommodate stack(s) 'reset' & to serve 'unref' ]

Lastly, all the 'itemize_stack' functions were tweaked
by eliminating an unnecessary initialization of result
unions. That objective was already accomplished by the
calloc() in a 'stacks_alloc' function or the remaining
'cleanup_stack' routine found in the <pids> interface.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: remove useless code for 2 'stacks_fetch' guys
Jim Warner [Thu, 9 May 2019 05:00:00 +0000 (00:00 -0500)]
library: remove useless code for 2 'stacks_fetch' guys

These changes are an outgrowth of the research/testing
behind the previous commit. There is no commingling of
select/reap stacks in interfaces beyond the <pids> api
since there's no need to support any 'reset' function.

However, those <pids> changes prompted a review of all
interfaces offering that 'stacks_fetch' function, thus
revealing 2 instances of useless logic/wasted efforts.

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: tweak support for get/select/reap, <PIDS> api
Jim Warner [Thu, 2 May 2019 05:00:00 +0000 (00:00 -0500)]
library: tweak support for get/select/reap, <PIDS> api

When the <pids> api was refactored in the commit shown
below, one objective was enabling the simultaneous use
of 'get' & 'select/reap' functions. Unlike other 'get'
functions, this <pids> 'get' acts as an iterator where
successive calls will return successive tasks/threads.

However, that goal wasn't quite met since a stack used
by 'get' was commingled with the 'select/reap' stacks.
Such commingling supported the 'reset' function, again
a provision which was unique to this <pids> interface.

Unfortunately, some poor assumptions in 'stacks_fetch'
produced a SEGV whenever 'reap/select' followed 'get'.
Thus, this patch addresses those issues and guarantees
such commingled stacks (extents) will be accommodated.

Reference(s):
. standardize portions of interface, <PIDS> api
commit 9ebadc1438a6665a98a9f0782523b0f9a2a6248f

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: correct 'vectorized' string logic, <PIDS> api
Jim Warner [Thu, 25 Apr 2019 05:00:00 +0000 (00:00 -0500)]
library: correct 'vectorized' string logic, <PIDS> api

The commit referenced below addressed (some) anomalies
surrounding 'strv' pointers. However, there remained a
couple quirks involving a potential NULL return value.

Any NULL values returned from the old library readproc
guys would cause no real harm for newlib. But they did
produce the misleading "[ duplicate ENUM_ID ]" result.

The following all represent potential NULL results and
suggest shortcomings in testing of that earlier patch.

. kernel threads do not have cgroup, cmdline & environ
. even if present environ could require root to access

So, this patch reverts a portion of the earlier commit
and ensures when some vectored string is not available
a traditional dash ('-') is the 'strv' returned value.

[ and we'll also correct one typo in the header file ]

Reference(s):
. eliminated a final potential NULL, <PIDS> api
commit 09503dc59792ab0147de604ab48342b8508f2d7b

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agomisc: adapted programs impacted by header file changes
Jim Warner [Wed, 13 Mar 2019 05:00:00 +0000 (00:00 -0500)]
misc: adapted programs impacted by header file changes

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: refactored some header file items and origins
Jim Warner [Tue, 12 Mar 2019 06:00:00 +0000 (00:00 -0600)]
library: refactored some header file items and origins

This commit is intended as a refinement of the patches
mentioned below, where origins/sources of newlib items
were added to the header files for user documentation.

However, if those additions are to be truly effective,
along with kernel documentation (where available), the
following prerequisites must also have been satisfied:
. our identifiers closely align with linux field names
. our derived items are documented or self-documenting

Satisfying those prerequisites prompted this patch and
for these changes, kernel sources were emphasized over
available documentation (shame on me, it should always
have been so). And, while some 'new' fields were found
to be conditional, they were included unconditionally.

These changes appear more extensive than they actually
need be since I have attempted to enforce some spacing
conventions. So, I've summarize the significant things
in the sections that follow. For a proper perspective,
use: 'git diff --ignore-space-change' (good as alias).

___________________________________________ <PIDS> api
This api is unique in that there exists many different
file/directory origins subordinate to /proc/<pid>. And
our item identifiers are sometimes coerced so as to be
able to group related or similar enumerators together.

So, users needed more help relating our identifiers to
an actual documented field. Thus, we will now also add
the field names as with 'stat: delayacct_blkio_ticks'.

Each item ending with a '_C' now consistently includes
both the parent's count/time plus waited for children.

That 'RTPRIO' guy was renamed/relocated as PRIORITY_RT
since its original name is an implementation artifact.

___________________________________________ <STAT> api
The only api change was to correct a typo ('dervied').

_________________________________________ <VMSTAT> api
Even ignoring white space, this interface received the
largest number of changes. Mostly, this was because of
deficiencies in the proc(5) documentation. Recall that
this documentation already sorely lacks any substance.
Usually, just kernel releases are noted, not contents.

When compared to kernel source, that proc(5) contained
many non-existent fields and also omitted many others.

________________________________________ <MEMINFO> api
Sadly, with this api many of the changes were simply a
correction of some earlier 'human error' where several
fields where hashed then tracked but never represented
with an item enumerator in this meminfo.h header file.

_______________________________________ <SLABINFO> api
The 'SLABS' (summary) & 'SLABNODE' items were reversed
since the former are derived from the separate caches.

More significantly, those 'SLABNODE' guys were renamed
to 'SLAB' since they concern individual caches and the
concept of 'nodes' is really an implementation detail.

Also, several enumerators were changed to more closely
agree with official slabinfo(5) documentation referred
to in what we're treating as a base document: proc(5).

Lastly, while those 'SLABS' items are solely a product
of our library and not represented in slabinfo(5), the
names attempt to parallel those found as 'SLAB' items.

______________________________________ <DISKSTATS> api
One enumeration identifier was changed so as to better
reflect its relationship to that actual documentation:
'Documentation/iostats.txt', as referenced in proc(5).

Reference(s):
. 12/2018, item origins added (and commit msg history)
commit 96d59cbf46b3ff687bd29fad4708074a0e1cea14
. 01/2019, <stat> origins tweaked
commit 201e816b26ddaccc923ec40977c92037cdd0c34e

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: repair any broken stuff found during refactor
Jim Warner [Mon, 11 Mar 2019 05:00:00 +0000 (00:00 -0500)]
library: repair any broken stuff found during refactor

Rather than offer three separate patches, they've been
consolidated in this single commit. All are related in
that they surfaced while preparing a subsequent patch.

------------------------------------------------------
library: correct a broken '#if define', <SLABINFO> api

It was introduced (embarrassingly) in the patch below.

Reference(s):
commit 97d078a9afbe4ed9949dc71acf7091fcf7971339

------------------------------------------------------
library: correct a broken 'GET' macro, <DISKSTATS> api

In the patch referenced below, which purported to make
all the 'GET' macros robust, the 'DISKSTATS_GET' macro
was broken. A necessary parameter wasn't passed to the
subsequently invoked function: procps_diskstats_get().

Reference(s):
commit bef8c7fb70164091071c792016371869b9c50ad2

------------------------------------------------------
library: correct a broken 'sort' func, <DISKSTATS> api

In the commit shown below, an attempt to normalize the
errno handling, the sort function inadvertently lost 1
crucial line of code which produces a consistent SEGV.

Reference(s):
commit 06be33b43e5ff3f2658e77ef79441ac2e970cfd7

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: tweak that lxc container support a final time
Jim Warner [Wed, 13 Feb 2019 06:00:00 +0000 (00:00 -0600)]
library: tweak that lxc container support a final time

Since the patch referenced below traded a compile-time
'sizeof' directive for a run-time 'strlen' call, there
is no need to declare lxc patterns as explicit arrays.

We'll also use the actual lxc patterns by omitting the
beginning slashes ('/') for both of those definitions.

And, looking to the future when most/all lxc users are
using the most recent lxc release, we will make things
slightly more efficient by reversing those two pattern
literals so the most recent pattern was checked first.

Of course, such a change only benefits tasks which are
running in a container. For the majority of processes,
both literals will be compared in that 'if' statement,
assuming the 'LXC' field is currently being displayed.

[ plus, a leftover parenthesis pair has been removed ]

Reference(s):
commit 288d759b8bdf22f194bdda88dbee0192bbc75bb0

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agolibrary: eliminate an unnecessary #include, <STAT> api
Jim Warner [Wed, 6 Feb 2019 06:00:00 +0000 (00:00 -0600)]
library: eliminate an unnecessary #include, <STAT> api

That patch shown below should have also included this.

Reference(s):
commit 68d7f7a673aee38238d054efe2fe207db245e3c5

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agotop: just correct a couple of misspellings in comments
Jim Warner [Fri, 1 Feb 2019 06:00:00 +0000 (00:00 -0600)]
top: just correct a couple of misspellings in comments

Signed-off-by: Jim Warner <james.warner@comcast.net>
5 years agopgrep.c: Match based on process run state for issue 109
ed [Thu, 3 Jan 2019 22:34:14 +0000 (22:34 +0000)]
pgrep.c: Match based on process run state for issue 109

References:
 procps-ng/procps#109

5 years agosysctl: do not report set key in case `close_stream` fails
Patrick Steinhardt [Tue, 29 May 2018 11:29:03 +0000 (13:29 +0200)]
sysctl: do not report set key in case `close_stream` fails

As we're using buffered I/O when writing kernel parameters, write errors
may get delayed until we close the `FILE` stream. As we are currently
outputting the key that is to be set disregarding the return value of
`close_stream`, we may end up in a situation where we report error and
success:

    $ sysctl kernel.printk_ratelimit=100000000000000
    sysctl: setting key "kernel.printk_ratelimit": error code 22
    kernel.printk_ratelimit = 100000000000000

Fix the issue by only outputting the updated value in case
`close_stream` does not report an error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
5 years agoprocio: fix potential out-of-bounds access when write fails
Patrick Steinhardt [Tue, 29 May 2018 11:20:00 +0000 (13:20 +0200)]
procio: fix potential out-of-bounds access when write fails

When writing to procfs via `proc_write` fails, we try to chunk the
buffer into smaller pieces to work around that issue. When searching for
the next location to split the buffer, though, we can underflow the
buffer in case the current offset is smaller than `LINELEN`. Fix the
issue by passing `cookie->offset` instead of `LINELEN` into `memrchr` in
case `cookie->offset` is smaller than `LINELEN`.

This bug can be triggered on musl-based systems, e.g. by executing

    $ sysctl kernel.printk_ratelimit=1000000000000000

As the value is out-of-range, `write` will return an error and set
`errno` to `EINVAL`. As we're only trying to write a smallish buffer
with a length smaller than `LINELEN` and as the buffer does not contain
any newlines, the call

    token = (char*)memrchr(cookie->buf+offset, '\n', LINELEN);

will underflow the buffer and crash the program.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
5 years agoprocio: use the user-supplied delimiter to split large input
Patrick Steinhardt [Fri, 8 Jun 2018 11:27:20 +0000 (13:27 +0200)]
procio: use the user-supplied delimiter to split large input

The `fprocopen` function allows users to specify a delimiter chacter
that is used to split very large input lines into smaller chunks. While
the code checks that the caller did actually supply the delimiter, it is
in fact never used to split the string. Instead, the hardcoded default
character ',' is always used to split the string.

Fix the issue by using `cookie->delim` instead.

5 years agodocs: fix "delimeter" typo in fprocopen man page
Patrick Steinhardt [Fri, 8 Jun 2018 11:26:46 +0000 (13:26 +0200)]
docs: fix "delimeter" typo in fprocopen man page