Commit Graph

2720 Commits

Author SHA1 Message Date
Jim Warner
605ea4a8f7 library: make that 'escape_str' private to our library
In that commit referenced below, a promise was made to
revisit an 'escape_str' function in efforts to make it
private to the library. The problem was it's needed by
both ps plus the library which is why it was exported.

So, in an effort to remove it from libprocps.sym, this
patch duplicates all the required code in ps/output.c.
Now, each version can be made private to their caller.

[ along the way we'll use this opportunity to remove ]
[ the 'restrict' qualifiers from function parameters ]
[ while swatting a compiler warning referenced below ]

Reference(s):
. April 2016, most escape functions made private
commit d916d5db86

proc/escape.c: In function `escape_command':
proc/escape.c:182:23: warning: initialization of `const char **' from incompatible pointer type `char **' [-Wincompatible-pointer-types]
  182 |     const char **lc = (char**)pp->cmdline;
      |                       ^

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Jim Warner
1aa8b16441 library: eliminated the questionable 'procps.h' header
There was a time when that procps.h file served a more
traditional role. Prior to the commit referenced below
it held just macros plus manifest constants. But, with
that change, such items were replaced with a series of
includes embracing all the library exported functions.

That approach was known to disguise errors which would
have otherwise yielded a compiler warning. And without
such a warning, there was no way to address the error.

So this patch will trade the all inclusive header file
approach for individual includes only where necessary.

Reference(s):
. April 2016, procps.h header file revamped
commit ccb6ae8de1
. Sept 2018, top abandoned use of procps.h
commit a6dfc2382e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Jim Warner
70fd03e461 library: size two read buffers with manifest constants
The meminfo & vmstat file read buffers are now defined
through symbolic constants next to the symbolic names.

[ recent attention to the /proc/stat buffer size led ]
[ to this (hopefully) better approach to definitions ]

Reference(s):
commit 81f4a6acdf

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Jim Warner
c8864e8010 misc: eliminate a couple of miscellaneous gcc warnings
This commit just address the two warnings shown below.

Reference(s):
pgrep.c: In function `select_procs':
pgrep.c:535:12: warning: variable `now' set but not used [-Wunused-but-set-variable]
  535 |     time_t now;
      |            ^~~

pidof.c: In function `select_procs':
pidof.c:201:9: warning: `stat_cmd' may be used uninitialized in this function [-Wmaybe-uninitialized]
  201 |        !strcmp(program, stat_cmd) ||
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-05 21:13:01 +10:00
Jan Rybar
97458da808 vmstat and watch manpage slight fixes
vmstat - align wording with proc manpage to clarify ambiguities  (rhbz#1796043)
watch - manpage presumes ntp tools are present by default (which they're not on rpm and deb distros, rhbz#1583669)
2020-07-01 08:05:53 +10:00
Jim Warner
81f4a6acdf library: raise amount by which the <stat> buffer grows
We won't go as far as the merge request shown below in
increasing buffer size, but we will reduce by half the
total iterations while growing it to achieve one read.

[ and this seems in line with what was recently done ]
[ to help top under a massively parallel environment ]
[ thru 2 abreast ('4') and combined cpus ('!') modes ]

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-29 21:13:40 +10:00
Jim Warner
3df74e7f3c 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>
2020-06-29 21:13:40 +10:00
Jim Warner
c02fc0b977 NEWS: updated for those recent utf-8 translation fixes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-29 21:13:40 +10:00
Jim Warner
65ec527e4c 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>
2020-06-25 20:08:22 +10:00
Jim Warner
df8fb11a47 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>
2020-06-25 20:08:22 +10:00
Jim Warner
9b3436e0e4 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>
2020-06-25 20:08:22 +10:00
Jim Warner
d64755ea5f 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>
2020-06-23 19:09:05 +10:00
Jim Warner
fc4fb85e7b 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 4217eddf47
. 04/19/16, create procps_pids_read_open.3
commit d48c54f679
. 01/05/17, create many procps_pids_... docs
commit 2598e9f2ce

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-23 19:09:05 +10:00
Jim Warner
eadb9db58f 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 fc69028d37

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-23 19:09:05 +10:00
Jim Warner
c934a3ab7a misc: respond to library rename of structs to 'reaped'
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-23 19:09:05 +10:00
Jim Warner
52c847a019 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>
2020-06-23 19:09:05 +10:00
Jim Warner
740e585b9d 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>
2020-06-23 19:09:05 +10:00
Jim Warner
356e9a0672 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>
2020-06-23 19:09:05 +10:00
Jim Warner
38537f79c7 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>
2020-06-23 19:09:05 +10:00
Craig Small
8b4228fe71 docs: some manpage fixes
Some editorial changes so the man pages follow the standards.

References:
 procps#173
2020-06-04 22:33:16 +10:00
Jim Warner
a3f8fa3763 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>
2020-06-04 20:19:03 +10:00
Jim Warner
ef5750765f 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>
2020-06-04 20:19:03 +10:00
Jim Warner
b46af6d213 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>
2020-05-31 22:06:26 +10:00
Jim Warner
98ae31584b 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>
2020-05-31 22:06:26 +10:00
Jim Warner
be3dcaa842 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>
2020-05-31 22:06:26 +10:00
Jim Warner
4c0b69f385 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>
2020-05-31 22:06:26 +10:00
Jim Warner
23224bb4af NEWS: acknowledge those two new top command provisions
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:49:40 +10:00
Jim Warner
2ca99a2ee4 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>
2020-05-28 19:49:40 +10:00
Jim Warner
c2d10e7f07 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>
2020-05-28 19:49:40 +10:00
Jim Warner
94d6db6b40 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>
2020-05-28 19:49:40 +10:00
Jim Warner
6e5f2c8de6 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>
2020-05-28 19:49:40 +10:00
Jim Warner
59f5a37a24 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>
2020-05-28 19:49:40 +10:00
Jim Warner
4c336ae9e6 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>
2020-05-28 19:49:40 +10:00
Jim Warner
46f7949845 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>
2020-05-28 19:49:40 +10:00
Craig Small
fc69028d37 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.
2020-05-19 22:43:21 +10:00
Craig Small
0aa0f92727 docs: Add namespace man pages 2020-05-18 21:42:49 +10:00
Craig Small
2b6ad61f3c docs: Update the uptime man pages
Three functions in the same manpage but use the so commands
to refer to the main man page.
2020-05-18 21:10:03 +10:00
Craig Small
9f751a7538 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
2020-05-17 23:00:27 +10:00
Craig Small
eeb8cf00a4 watch: add additional notes about environment
References:
 procps-ng/procps!62
 commit d3e0ff5a0a
2020-05-12 19:30:28 +10:00
Harry Wagstaff
09b62573b1 Add information on WATCH_INTERVAL env var to watch documentation 2020-05-12 19:25:38 +10:00
Harry Wagstaff
f0a3cd4b1f Add ability to specify watch interval using environment variable WATCH_INTERVAL 2020-05-12 19:25:26 +10:00
Craig Small
48a201c46f 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 01c1b2345e
2020-05-12 19:06:34 +10:00
Ivan Skytte Jørgensen
236b956c69 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
2020-05-12 19:03:34 +10:00
Dylan Swiggett
59e378642e 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)).
2020-05-11 17:44:48 +10:00
Arun Chandrasekaran
cd7ea2abf3 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>
2020-05-11 17:36:12 +10:00
Craig Small
557fda8f98 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 7d55409b82
 commit 2b804a532a
2020-05-11 16:59:18 +10:00
Arun Chandrasekaran
89392e67a9 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>
2020-05-11 16:59:14 +10:00
Craig Small
7f44382938 kill: Adjust documentation for sigqueue
Added NEWS item
Changed the section for sigqueue as its 3 for me.
2020-05-11 16:51:28 +10:00
Wieland Hoffmann
4649c52249 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.
2020-04-24 18:56:16 +10:00
Craig Small
fb0915c3ca 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.
2020-04-24 17:49:12 +10:00