]> granicus.if.org Git - procps-ng/log
procps-ng
3 years agotop: In the bye_bye function, replace fputs with the write interface.
Shaohua Zhan [Thu, 3 Dec 2020 02:24:09 +0000 (10:24 +0800)]
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>
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 agoNEWS: tweak wording associated with library versioning v3.3.17
Jim Warner [Mon, 8 Feb 2021 16:10:10 +0000 (10:10 -0600)]
NEWS: tweak wording associated with library versioning

Signed-off-by: Jim Warner <james.warner@comcast.net>
3 years agolibrary: Version has revision incremented
Craig Small [Mon, 8 Feb 2021 10:36:05 +0000 (21:36 +1100)]
library: Version has revision incremented

Library had only its revision incremented to three as there were only
internal changes.

References:
 commit 0d386260b4b007e65172d137924db6e4e4e994cd
 commit eea5626bb144328eb60e9ea8a29bd5b1f100ecd9
 commit 1b9ea61116a625456a89dd7d26b3e4c3d390a599
 commit b0c8e3408b0c0e8e2b41e704083139ab791194a1
 commit e3196502784b11c70d6e3c33159403d2f7c118e1
 commit bb1a79f2c837cad238c2576d2b2705f9cc781c35
 commit b52a26740445904c01233166271817743f2e4b40
 commit 8e0c33be46820c11bb7a911ae0f67fd390864058

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agobuild-sys: Don't require po4a for installation
Craig Small [Mon, 8 Feb 2021 10:23:41 +0000 (21:23 +1100)]
build-sys: Don't require po4a for installation

The build system tested for the presence of po4a binary at the
install step. procps ships with translated man pages so doesn't
need po4a for install/uninstallation.

Works already in psmisc!

References:
 https://gitlab.com/psmisc/psmisc/-/commit/5fab6b7ab385080f1db725d6803136ec1841a15f

Signed-off-by: Craig Small <csmall@dropbear.xyz>
3 years agonls: Fix translation problems
Craig Small [Fri, 29 Jan 2021 23:38:30 +0000 (10:38 +1100)]
nls: Fix translation problems

Some of the translation files did not escape the < properly leading
to po4a aborting.  Also some translators are using old templates
and this merges them to the new ones.

References:
 procps-ng/procps#188

3 years agonls: Update the translation files
Craig Small [Thu, 28 Jan 2021 11:39:49 +0000 (22:39 +1100)]
nls: Update the translation files

Download of the translation files from the translation
project.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
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 agomisc: Update NEWS to next version v3.3.17rc1
Craig Small [Fri, 22 Jan 2021 07:21:08 +0000 (18:21 +1100)]
misc: Update NEWS to next version

3 years agonls: Minor update to po files
Craig Small [Fri, 22 Jan 2021 07:19:05 +0000 (18:19 +1100)]
nls: Minor update to po files

3 years agobuild-sys: One more man-po build fix
Craig Small [Thu, 21 Jan 2021 10:58:48 +0000 (21:58 +1100)]
build-sys: One more man-po build fix

3 years agobuild-sys: Update build to install translated manpages
Craig Small [Thu, 21 Jan 2021 10:40:10 +0000 (21:40 +1100)]
build-sys: Update build to install translated manpages

Based on the psmisc build system this now installs the
translated man pages and seems to survive a make distcheck

3 years agobuild-sys: Fix version directory
Craig Small [Thu, 21 Jan 2021 10:01:33 +0000 (21:01 +1100)]
build-sys: Fix version directory

.version needs to be generated into the build directory not the
source directory.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
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>
4 years agotop: tweak cmd/cmdline logic for a possible bad locale
Jim Warner [Fri, 1 Jan 2021 06:00:00 +0000 (00:00 -0600)]
top: tweak cmd/cmdline logic for a possible bad locale

Since this master library isn't quite as sophisticated
as the newlib version, this patch will protect against
the possibility of multibyte characters in a program's
name combined with some locale without UTF-8 encoding.

[ it is better to treat the COMMAND column length as ]
[ more than what's actually printed than to have the ]
[ line overflow & corrupt the remaining screen lines ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: let's make 'escaped_copy' multibyte aware too
Jim Warner [Thu, 31 Dec 2020 06:00:00 +0000 (00:00 -0600)]
library: let's make 'escaped_copy' multibyte aware too

This patch is intended to bring the master branch into
closer alignment with the newlib branch functionality.

The commit shown below replaced that 'escape_str' with
'escaped_copy' so that the ps program wouldn't execute
some code twice. However, it created a problem for the
top program when the UTF-8 encoding was not available.

Unlike ps who calls the escape functions directly, top
outputs those library provided strings unaltered. That
means there is no workaround (like LANG=) when such an
encoding was unavailable. This, in turn, can lead to a
corrupted display (especially with the linux console).

Now, when a UTF-8 encoding is not available, multibyte
chars are converted to '?', reducing display problems.

[ there's still a potential problem concerning 'cmd' ]
[ should program names contain multibyte characters. ]
[ unlike that newlib branch, this string is not ever ]
[ altered with the '?' char under the master branch. ]

Reference(s);
. Dec 2020, escaoed_copy repleced most escape_str
commit eea5626bb144328eb60e9ea8a29bd5b1f100ecd9

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agolibrary: help ensure 'escape_str' isn't executed twice
Jim Warner [Sat, 26 Dec 2020 06:00:00 +0000 (00:00 -0600)]
library: help ensure 'escape_str' isn't executed twice

Now that the ps program is using 'escape_str' for most
of the library's returned strings, this patch tries to
lessen the prospects of executing that function twice.

Our newlib branch has achieved such a goal through the
elimination of nearly all escape.c code. However, here
we avoid API change by trading some 'escape_str' calls
(with wide character overhead) for a slightly extended
'escaped_copy' call (which incurs no multibyte costs).

Note: until we migrate to the newlib version, there is
a remaining call to 'escape_str' which we can't avoid.
Such code involves the 'escape_command' function call.

[ As we prepare for this new (final?) release, there ]
[ were already internal library changes that require ]
[ a new 'revision'. This patch won't impact the API! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: added utf8 multibyte support to additional fields
Jim Warner [Thu, 24 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 [Thu, 24 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 contain multibyte characters (like supgid). 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.

[ note: unlike the newlib guy, the master ps program ]
[ cannot properly handle utf8 multibyte sequences in ]
[ in the recently introduced 'exe' field shown below ]

Reference(s):
. Jun 2018, introduced 'exe' field
commit b556bf5ba82c7e593eb682bbf836c2bc444b2e7d
. May 2011, original escaped_copy (cmdline, cgroup)
commit 7b0fc19e9d28380dc9790615b93bc3653d6d686e

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: correct one spelling oops in a programmer comment
Jim Warner [Tue, 22 Dec 2020 06:00:00 +0000 (00:00 -0600)]
top: correct one spelling oops in a programmer comment

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agomisc: Add NEWS for ps sorting
Craig Small [Tue, 22 Dec 2020 05:26:35 +0000 (16:26 +1100)]
misc: Add NEWS for ps sorting

4 years agoMerge branch 'topimiettinen/procps-ps-sort-label'
Craig Small [Tue, 22 Dec 2020 05:24:47 +0000 (16:24 +1100)]
Merge branch 'topimiettinen/procps-ps-sort-label'

References:
 procps-ng/procps!99

4 years agops: add lots of sorting functions
Topi Miettinen [Wed, 11 Mar 2020 09:23:33 +0000 (11:23 +0200)]
ps: add lots of sorting functions

Use NULL in format_array to indicate that the print function shall be
used also for sorting. Change sr_nop() to NULL for all fields which
don't use pr_nop() for printing.

Before the commit (note that '--sort label' has no effect: the rows
are not sorted according to label field):
$ ps -A -o command,label --sort label | grep /lib/systemd
/lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0
/lib/systemd/systemd-udevd  system_u:system_r:udev_t:s0-s0:c0.c1023
/lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0
/lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0
/lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0
/lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0
/lib/systemd/systemd --user user_u:user_r:user_t:s0
/lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023
grep /lib/systemd           user_u:user_r:user_t:s0

After the commit, '--sort label' works and the output is sorted:
$ ps -A -o command,label --sort label | grep /lib/systemd
/lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023
/lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0
/lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0
/lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0
/lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0
/lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0
/lib/systemd/systemd-udevd  system_u:system_r:udev_t:s0-s0:c0.c1023
/lib/systemd/systemd --user user_u:user_r:user_t:s0
grep /lib/systemd           user_u:user_r:user_t:s0

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
4 years agopgrep: Remove memory leak
Craig Small [Tue, 22 Dec 2020 05:08:49 +0000 (16:08 +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 agoMerge branch 'axxName/procps-master'
Craig Small [Tue, 22 Dec 2020 04:43:07 +0000 (15:43 +1100)]
Merge branch 'axxName/procps-master'

References:
 procps-ng/procps!63

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 agops: Add NEWS and test for exe output
Craig Small [Tue, 22 Dec 2020 04:31:39 +0000 (15:31 +1100)]
ps: Add NEWS and test for exe output

Only need this for master, as Jim took care of exe
handling for newlib in the ad4269 change.

References:
 commit b556bf5ba82c7e593eb682bbf836c2bc444b2e7d
 commit ad4269f1189d5a7d68765e291bcfa981b6731c25

4 years agops: new format option 'exe' now shows executable path if unavail from cmdline
Jan Rybar [Fri, 8 Jun 2018 14:38:14 +0000 (16:38 +0200)]
ps: new format option 'exe' now shows executable path if unavail from cmdline

Red Hat Bugzilla #1399206

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 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 agow: Use POSIX <utmpx.h> functions where available
A. Wilcox [Sat, 16 Jun 2018 07:26:53 +0000 (02:26 -0500)]
w: Use POSIX <utmpx.h> functions where available

<utmp.h> has been deprecated since 2001 in favour of <utmpx.h>.

On glibc systems, utmp is just an alias to utmpx, so there is no
functional change using one over the other.

However, on the musl libc, a library (utmps) can be used to provide
utmpx functionality - but not utmp.  This means that procps either
doesn't work properly (`w` shows nothing under musl with default no-op
implementation), or fails to build (utmps provides utmpx.h but no
utmp.h).

This commit will use utmpx.h where available, which allows `w` to work
correctly with utmps and has no change on glibc systems.

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 agoNEWS: Add notice for pidof -q
Craig Small [Tue, 22 Dec 2020 03:32:03 +0000 (14:32 +1100)]
NEWS: Add notice for pidof -q

4 years agopidof: allow to suppress output
Matteo Croce [Tue, 19 Mar 2019 13:33:01 +0000 (14:33 +0100)]
pidof: allow to suppress output

Often pidof is used in shell scripts in this form:

    if pidof daemon >/dev/null; then
        ...
    fi

The redirection to /dev/null is needed because otherwise the script
would output the found PIDs.
Let's add a -q option which, similary to grep, just sets the exit code.
Also exit on first match, as there is no reason to proceed further when
at least a process is matched.

Tested with:

    $ ./pidof bash
    17701 14019 5276 2967
    $ echo $?
    0
    $ ./pidof bashx
    $ echo $?
    1
    $ ./pidof -q bash
    $ echo $?
    0
    $ ./pidof -q bashx
    $ echo $?
    1

4 years agokill: Fix argument handling for negative PIDs
Raphaël Jakse [Fri, 7 Sep 2018 12:57:03 +0000 (12:57 +0000)]
kill: Fix argument handling for negative PIDs

4 years agoMerge branch 'nipunn1313/procps-watch_colors2'
Craig Small [Tue, 22 Dec 2020 02:54:50 +0000 (13:54 +1100)]
Merge branch 'nipunn1313/procps-watch_colors2'

References:
 procps-ng/procps!109

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 agoSupport simple 8 bit ansi escape sequences
Nipunn Koorapati [Thu, 2 Jul 2020 06:05:24 +0000 (06:05 +0000)]
Support simple 8 bit ansi escape sequences

See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
Support standard and high intensity colors. The default
ncurses colors ARE the high intensity colors - represented
via an 8 bit ansi escape sequence here.

4 years agoMerge branch 'nipunn1313/procps-watch_colors'
Craig Small [Tue, 22 Dec 2020 02:48:15 +0000 (13:48 +1100)]
Merge branch 'nipunn1313/procps-watch_colors'

References:
 procps-ng/procps!106

4 years agoSpaces to tabs
Nipunn Koorapati [Mon, 13 Jul 2020 03:20:23 +0000 (03:20 +0000)]
Spaces to tabs

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 agoSupport simple 8 bit ansi escape sequences
Nipunn Koorapati [Thu, 2 Jul 2020 06:05:24 +0000 (06:05 +0000)]
Support simple 8 bit ansi escape sequences

See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
Support standard and high intensity colors. The default
ncurses colors ARE the high intensity colors - represented
via an 8 bit ansi escape sequence here.

4 years agoMerge branch 'antonblanchard/procps-proc-stat-buffer'
Craig Small [Tue, 22 Dec 2020 02:18:58 +0000 (13:18 +1100)]
Merge branch 'antonblanchard/procps-proc-stat-buffer'

References:
 procps-ng/procps!105

4 years agoIncrease BUFFSIZE to handle very large /proc/stat files
Anton Blanchard [Thu, 25 Jun 2020 23:06:12 +0000 (09:06 +1000)]
Increase BUFFSIZE to handle very large /proc/stat files

We read /proc/stat using a statically sized buffer. This was increased
to 64kB in 2005 via commit 777fcd3cf15d "/proc/stat for 1024 CPUs".

Unfortunately in 2020, 1024 CPUs is not enough for anyone. I have a
large machine where /proc/stat is 74kB, and vmstat gives incorrect
output.

Double the buffer to 128kB in the confidence that 2048 CPUs is actually
enough for anyone.

Signed-off-by: Anton Blanchard <anton@ozlabs.org>
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 agoMerge branch 'alxu/procps-pwait'
Craig Small [Tue, 22 Dec 2020 01:16:09 +0000 (12:16 +1100)]
Merge branch 'alxu/procps-pwait'

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

References:
 procps-ng/procps!97

Signed-off-by: Craig Small <csmall@dropbear.xyz>
4 years agopgrep: add pwait
Alex Xu (Hello71) [Mon, 24 Feb 2020 03:02:59 +0000 (22:02 -0500)]
pgrep: add pwait

4 years agoMerge branch 'nipunn1313/procps-spaces_to_tabs'
Craig Small [Tue, 22 Dec 2020 00:55:10 +0000 (11:55 +1100)]
Merge branch 'nipunn1313/procps-spaces_to_tabs'

References:
 procps-ng/procps!108

4 years agoConvert spaces to tabs in watch.c
Nipunn Koorapati [Mon, 13 Jul 2020 03:24:53 +0000 (03:24 +0000)]
Convert spaces to tabs in watch.c

4 years agoMerge branch 'nipunn1313/procps-configure_ncurses'
Craig Small [Tue, 22 Dec 2020 00:45:47 +0000 (11:45 +1100)]
Merge branch 'nipunn1313/procps-configure_ncurses'

Macs have the wide stuff in the ncurses (not ncursesw) library.

References:
 procps-ng/procps!110
 procps-ng/procps#47

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 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 agoMerge branch 'brenns10/procps-master'
Craig Small [Tue, 22 Dec 2020 00:08:52 +0000 (11:08 +1100)]
Merge branch 'brenns10/procps-master'

References:
 procps-ng/procps!119

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 agoMerge branch 'ratijas/procps-man-watch'
Craig Small [Tue, 22 Dec 2020 00:03:57 +0000 (11:03 +1100)]
Merge branch 'ratijas/procps-man-watch'

References:
 procps-ng/procps!121

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 agotop: a small safeguard added to the ATEOJ_RPTHSH logic
Jim Warner [Mon, 19 Oct 2020 05:00:00 +0000 (00:00 -0500)]
top: a small safeguard added to the ATEOJ_RPTHSH logic

If a hash results report was output (via ATEOJ_RPTHSH)
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) ]
[ and then arrange to trigger the end-of-job 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 agofree,slabtop,uptime: complain about extra ops
Craig Small [Mon, 19 Oct 2020 11:36:06 +0000 (22:36 +1100)]
free,slabtop,uptime: complain about extra ops

free, slabtop and uptime would happily take extra command line
arguments and doing nothing about them. The programs now check
optind after option processing and will give you usage screen
if there is anything extra.

References:
 procps-ng/procps#181

4 years agowatch: Add no linewrap option
Craig Small [Mon, 19 Oct 2020 11:03:44 +0000 (22:03 +1100)]
watch: Add no linewrap option

For long lines from a process, watch would wrap them around to the
next. While this default option has it uses, sometimes you want to
just cut those long lines down.

watch has a -w flag which will truncate the lines to the number
of columns. A few simple lines to do this new trick.

I think I caught all the ANSI state correctly but there might be
a chance it bleeds to the next row.

References:
 procps-ng/procps#182

4 years agotop: just a small tweak to that history hash algorithm
Jim Warner [Thu, 1 Oct 2020 05:00:00 +0000 (00:00 -0500)]
top: just a small tweak to that history hash algorithm

This patch just raises the size of the hash table used
to calculate elapsed task stuff. The net result should
be less need for 'chaining' under pid hash collisions.

[ the hash scheme is intentionally kept as primitive ]
[ and, therefore, as fast as possible. it employs an ]
[ 'and' approach versus a 'mod' operation since both ]
[ yield similar distribution but the former approach ]
[ was 4 fewer cpu instructions in terms of overhead. ]

[ additionally, for hash collisions, 'chaining' uses ]
[ an array index rather than the usual pointer since ]
[ the HST_t guys may move when they are reallocated. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agops: Match on truncated 16 char for -C
Craig Small [Thu, 24 Sep 2020 12:01:22 +0000 (22:01 +1000)]
ps: Match on truncated 16 char for -C

The referenced commit the comm length was increased from 16 to 64
characters to handle the larger command names for things like kernel
threads.

However most user processes are limited to 15 characters which means
if you try something like ps -C myprogramisbiggerthansixteen this would
fail to match because /proc/<PID>/comm would only be myprogramisbigg

ps now checks the comm length and if it is 15 and if the given match
is 15 or more, it will only match the first 15 characters.

This is also how killall has worked for about a year.

Thanks to Jean Delvare <jdelvare@suse.de> for the note.

References:
 commit 14005a371e5c14289e96a4927ffd1a827d3c9d85
 commit psmisc/psmisc@1188315cd037d73bf946a0003b70c6423cc330d2

Signed-off-by: Craig Small <csmall@dropbear.xyz>
4 years agotop: fix additional SEGVs if no tasks were displayable
Jim Warner [Sun, 13 Sep 2020 05:00:00 +0000 (00:00 -0500)]
top: fix additional SEGVs if no tasks were displayable

This patch is an outgrowth of that commit shown below.

Many additional potential segmentation faults might be
encountered if interactive commands are opened up to a
user when a '-p' switch has a single non-existent pid.

[ always the 'k', 'L', 'r', 'Y' keys & maybe 'v' too ]

So, this patch will restrict such a loser (oops, user)
to a reduced subset of normal commands until he/she/it
quits then restarts top with something to be displayed
or issues the '=' command overriding that '-p' switch.

Reference(s):
commit f57a0301e3adfa5fd456404a200182c7f21da03a

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: fix potential SEGV when no tasks were displayable
Jim Warner [Wed, 9 Sep 2020 05:00:00 +0000 (00:00 -0500)]
top: fix potential SEGV when no tasks were displayable

This patch fixes a nearly decade old bug discovered by
Frederik Deweerdt. His merge request shown below would
be an adequate solution except for iterative overhead.

This alternate patch will represent substantially less
overhead for an admittedly extremely rare possibility.

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

And-thanks-to: Frederik Deweerdt <fdeweerdt@fastly.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: update user/system cpu % graph content (man page)
Jim Warner [Tue, 8 Sep 2020 05:00:00 +0000 (00:00 -0500)]
top: update user/system cpu % graph content (man page)

What had been stated as the contents of the cpu graphs
was never really inclusive enough. Those recent newlib
tweaks highlighted the need for these man doc changes.

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agobuild-sys: updated autoscan for that configure.ac file
Jim Warner [Sun, 30 Aug 2020 05:00:00 +0000 (00:00 -0500)]
build-sys: updated autoscan for that configure.ac file

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: even more useless cosemetic stuff (only comments)
Jim Warner [Fri, 21 Aug 2020 05:00:00 +0000 (00:00 -0500)]
top: even more useless cosemetic stuff (only comments)

[ this is what happens when i've run out of bugs and ]
[ issues and am now left with way too much free time ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: more useless cosemetic changes (chiefly comments)
Jim Warner [Thu, 20 Aug 2020 05:00:00 +0000 (00:00 -0500)]
top: more useless cosemetic changes (chiefly comments)

All of these changes are self-explanatory, so I'll not
provide any more comments thus avoiding further shame.

[ everything's perfectly justified and right margins ]
[ are filled entirely, but of course it must be luck ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agomisc: eliminate a couple of miscellaneous gcc warnings
Jim Warner [Sat, 25 Jul 2020 05:00:00 +0000 (00:00 -0500)]
misc: eliminate a couple of miscellaneous gcc warnings

This commit just addresses those warnings shown below.

Reference(s):
proc/sysinfo.c: In function `getrunners':
proc/sysinfo.c:491:26: warning: `%s' directive writing up to 255 bytes into a region of size 26 [-Wformat-overflow=]
  491 |     sprintf(tbuf, "/proc/%s/stat", ent->d_name);
      |                          ^~

pgrep.c: In function `select_procs':
pgrep.c:591:11: warning: suggest explicit braces to avoid ambiguous `else' [-Wdangling-else]
  591 |   else if (opt_older)
      |           ^

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: for consistency, reposition a few man page macros
Jim Warner [Thu, 23 Jul 2020 05:00:00 +0000 (00:00 -0500)]
top: for consistency, reposition a few man page macros

This patch just repositions some .PP macros so they'll
immediately precede the paragraphs to which they apply
rather than a comment line used as a visual separator.

[ ok we also update the document date to 'July 2020' ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agobuild-sys: suppress '-Wunused-result' with AM_CPPFLAGS
Jim Warner [Tue, 14 Jul 2020 05:00:00 +0000 (00:00 -0500)]
build-sys: suppress '-Wunused-result' with AM_CPPFLAGS

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: address several 'mandoc -Tlint' errors & warnings
Jim Warner [Fri, 10 Jul 2020 05:00:00 +0000 (00:00 -0500)]
top: address several 'mandoc -Tlint' errors & warnings

This commit addresses the errors/warnings shown below.

Reference(s):
ERROR: skipping end of block that is not open: RE
WARNING: skipping paragraph macro: sp after PP
WARNING: skipping paragraph macro: PP empty

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: make that 'cpu_prt' function a tad more efficient
Jim Warner [Thu, 9 Jul 2020 05:00:00 +0000 (00:00 -0500)]
top: make that 'cpu_prt' function a tad more efficient

This commit only eliminates two 'nop' instructions and
one 'jmp' instruction. However, it makes that C source
code look a little bit prettier than it looked before.

[ and yes, some unnecessary parenthesis were used to ]
[ force an alignment of some related lines. it costs ]
[ us nothing in extra code yet helps in readability. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: make the 'cpu_tics' function a tad more efficient
Jim Warner [Wed, 8 Jul 2020 05:00:00 +0000 (00:00 -0500)]
top: make the 'cpu_tics' function a tad more efficient

This patch eliminates one variable which resulted in a
corresponding elimination of three 'mov' instructions.

[ that was 6 bytes per 'mov' for a total of 18 bytes ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agoMerge branch 'jrybar/procps-vmstat-watch-manpage-fix'
Craig Small [Tue, 30 Jun 2020 22:04:51 +0000 (08:04 +1000)]
Merge branch 'jrybar/procps-vmstat-watch-manpage-fix'

References:
 procps-ng/procps!103

4 years agovmstat and watch manpage slight fixes
Jan Rybar [Thu, 30 Apr 2020 15:06:18 +0000 (17:06 +0200)]
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)

4 years agotop: raise the amount by which top's stat buffer grows
Jim Warner [Fri, 26 Jun 2020 05:00:00 +0000 (00:00 -0500)]
top: raise the amount by which top's stat buffer grows

We won't go as far as the merge request shown below in
increasing buffer size, but we'll reduce substantially
total iterations while growing it to achieve one read.

[ and this seems in line with what was recently done ]
[ to accommodate the massively parallel environments ]
[ 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>
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: provide for zero length character in utf8 support
Jim Warner [Fri, 19 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 [Thu, 18 Jun 2020 05:00:00 +0000 (00:00 -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 [Tue, 16 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

The previous PRETEND8CPUS #define was recently 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: bump up that PRETEND8CPUS #define to PRETEND48CPU
Jim Warner [Sun, 24 May 2020 05:00:00 +0000 (00:00 -0500)]
top: bump up that PRETEND8CPUS #define to PRETEND48CPU

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
4 years agotop: add '!' toggle for combined cpus display, man doc
Jim Warner [Thu, 21 May 2020 05:00:00 +0000 (00:00 -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 [Thu, 21 May 2020 05:00:00 +0000 (00:00 -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 [Wed, 13 May 2020 12:02:43 +0000 (07:02 -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 [Wed, 13 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 [Tue, 5 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 agobuild-sys: Some version fixes
Craig Small [Fri, 22 May 2020 07:11:13 +0000 (17:11 +1000)]
build-sys: Some version fixes

tarball-version should be shipped in tarball
version is not.

4 years agoNEWS: add pgrep older than item
Craig Small [Sun, 17 May 2020 12:00:51 +0000 (22:00 +1000)]
NEWS: add pgrep older than item