Commit Graph

279 Commits

Author SHA1 Message Date
Craig Small
4c23fcfd3c docs: Mention stime in ps.1
References:
 procps-ng/procps#164
2020-04-07 19:35:27 +10:00
Craig Small
0afe595a44 NEWS: Fix location of sysctl update
The previous commit put the sysctl directory order entries in
the wrong place.
2020-02-27 22:03:12 +11:00
Craig Small
24a1574f0a sysctl: config directory order
Matches the systemd directory order (/run is after /etc) and
document what directories are used better.
2020-02-27 21:58:07 +11:00
Jim Warner
5cd29e5093 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 291d98ee50
. original 3.3.15 validation logic
commit fdb58974e2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-02-18 11:20:58 +11:00
Craig Small
6164fbb829 NEWS: Add missing pgrep note 2020-02-06 22:09:56 +11:00
Craig Small
59c88e18f2 v3.3.16 release 2019-12-08 15:06:03 +11:00
Craig Small
d063bfc59e library: Adjust version for release
Previous release incremented the age instead of incrementing the
revision. The age can only increment if revision (internal changes
only) or current (API changes) also increments.

A C:R:A of 8.0.2 means its the latest revision of 8.0 library and
any binary linked against 8.0 will work. This is our third revision
of the 8.0 library.

References:
 https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
2019-12-08 14:56:53 +11:00
Craig Small
e79095ddcc build-sys: Install translated manpages
References:
 procps-ng/procps#146
2019-10-31 20:48:15 +11:00
Craig Small
a2b7106793 snice: Fix matching on PID
@MarsChan correctly pointed out that the read() always returns 128
bytes, so skipping on >= 128 will always mean we skip. Their suggestion
was to remove the equality, but read will never go past 128 bytes so
I just removed that part of the check.

References:
 procps-ng/procps!89
2019-10-22 08:14:35 +11:00
Jim Warner
4c4d8b2464 NEWS: add a new item (top), fix one other item (pgrep)
Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-08-25 10:35:50 +10:00
Jim Warner
e7aa90a866 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>
2019-07-04 20:42:27 +10:00
Craig Small
2fa3bb0669 misc: update for pgrep runstate
Added some minor fixes and notes
2019-03-05 07:59:48 +11:00
Craig Small
bb272580a6 docs: Update ps.1 to warn about command name length
Previous versions of ps used to only match on the first 15 characters
because that's what the kernel used to provide. Newer kernels have a
longer length for this field so procps has been updated to suit.

References:
 procps-ng/procps#101
 https://bugzilla.suse.com/show_bug.cgi?id=1099091
2018-08-08 20:13:58 +10:00
Jim Warner
38a668909f top: parent total cpu includes collapsed children, doc
Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-07-17 21:00:51 +10:00
Jim Warner
3943b185a9 top: allow collapsible forest view children, documents
Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-23 22:03:57 +10:00
Jim Warner
06d4d985a6 top: 'other filters' saved with config file, documents
Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-23 22:03:56 +10:00
Jim Warner
cf057d2fe5 top: provide the means to exploit a 256-color terminal
With the Qualys security audit, we began to harden our
treatment of the top rcfile. In particular, the values
read were checked so as to prevent some malicious user
from editing it in order to achieve an evil objective.

However when it came to colors I was surprised to find
that at least one user edited the rcfile for 256-color
support. Unfortunately, our new checks prevented this.

So this commit will provide the means to exploit those
extra colors with no need to manually edit the rcfile.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-07 21:35:59 +10:00
Craig Small
c51b329a32 docs: use correct units in free.1
The free manpage used the correct unit names (e.g. membibyte) but the
incorrect unit (e.g. M ) for the human-readable option.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2018-05-31 20:34:13 +10:00
Craig Small
59c5133ff1 misc: Reorder NEWS 2018-05-20 07:34:17 +10:00
Craig Small
14005a371e ps: Increase command selection field to 64
The library now presents command names up to 64 characters, in line with
the kernel changes.  ps command name selection (the -C option) now also
is 64 characters long.

References:
 commit 2cfdbbe897
2018-05-19 22:10:11 +10:00
Craig Small
c32ab58b94 pgrep: Remove >15 warning
As comm length can be longer than 15 characters with newer kernels, it
doesn't make sense to have a warning when you make the match string
longer than this.

As a side-effect, it removes the false-positive you got when you used
long regex matches (see issue #92 )

References:
 commit 2cfdbbe897
 procps-ng/procps#92
2018-05-19 08:14:06 +10:00
Craig Small
52dc8dcdea misc: Update NEWS with CVE and library changes 2018-05-19 08:11:23 +10:00
Craig Small
75bd099420 library: check not undef SIGLOST
sig.c had this odd logic where on non-Hurd systems it would undefine
SIGLOST. Fine for Hurd or amd64 Linux systems. Bad for a sparc which
has SIGLOST defined *and* is not Hurd.

Just check its defined, its much simpler.
2018-05-03 21:06:05 +10:00
Craig Small
5576c8e438 library: build on non-glibc systems
Some non-glibc systems didn't have libio.h or __BEGIN_DECLS
Changes to make it more standard.

References:
 issue #88
2018-04-10 21:28:11 +10:00
Craig Small
58bff862fc free: fix scaling on 32-bit systems
Systems that have a 32-bit long would give incorrect results in free.

References:
 Issue #89
 https://www.freelists.org/post/procps/frees-scale-size-broken-with-32bit-long
2018-04-10 21:20:25 +10:00
Craig Small
1982a79ba8 misc: Update news about #91 2018-04-10 21:16:10 +10:00
Craig Small
0b488c7f5c pgrep: Don't segfault with no match
If pgrep is run with a non-program name match and there are
no matches, it segfaults.

The testsuite thinks zero bytes sent, and zero bytes sent
because the program crashed is the same :/

References:
 commit 1aacf4af7f
 https://bugs.debian.org/894917

Signed-off-by: Craig Small <csmall@enc.com.au>
2018-04-06 23:00:29 +10:00
Craig Small
e22a5087dd 3.3.13 release candidate 1
Update NEWS with the version
Add library API change into NEWS
Update c:r:a for library to 7:0:1

This means the current and age are incremented, so old programs can
use new library but not vice-versa as they won't have the numa*
functions.
2018-03-12 16:30:58 +11:00
Craig Small
8954e4349c misc: update NEWS with some missed items 2018-03-03 18:59:17 +11:00
Craig Small
5d0b094b8c ps: Add NEWS and checks for times and cputimes
The previous commit had one minor bug in it because the fields need
to be alphabetical and times comes after timeout.

Added NEWS item for this feature
Added another testsuite check for new flags in case they
disappear or go strange one day.

References:
 commit 8a94ed6111
2018-03-02 22:07:46 +11:00
Craig Small
cd289c88a0 misc: Add news entry for previous pidof 2018-03-02 21:47:50 +11:00
Craig Small
063838a7f5 docs: Change name of fprocopen man page
Add NEWS for sysctl large buffers
Rename manpage to fprocopen

References:
 be6b048a41
 procps-ng/procps!56
2018-02-28 21:24:03 +11:00
Craig Small
e82dd07b3b free: Update tests and fix for previous patch
The previous two patches updated free, but needed a tweak and the tests
also needed to be updated. I've hand-calculated the results using bc and
both the testsuite and bc results equal what free prints out.

References:
 commit 9365be7633
 procps-ng/procps#45
2018-01-13 16:09:54 +11:00
Craig Small
a238a687ce docs: Document I idle state in ps and top
Linux 4.2 provided a new process state of I which is used for an idle
kernel thread. This new state means that kernel threads do not
contribute to the loadavg as they are no longer state D or S but I.

While both ps and top displayed this state, it wasn't documented in
either manual page until now.

References:
 https://bugs.debian.org/886967
 https://www.quora.com/What-does-mean-Linux-process-state-I-in-the-top-output
 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=80ed87c8a9ca0cad7ca66cf3bbdfb17559a66dcf
2018-01-13 11:18:09 +11:00
Craig Small
272c5b0f8c sysctl: Don't crash file fopen fails
The commit referenced below put a setvbuf() before checking what
fopen() returned. If the file could not be opened then the file
handle was NULL at setvbuf() crashed.

setvbuf() is now called after checking what fopen() returns and only
when it was successful.

References:
 procps-ng/procps#76
 commit 58ae084c27
2018-01-07 12:25:35 +11:00
Craig Small
2da3c0c5bf Add news for previous commit
References:
 procps-ng/procps!55
 387e2cf
2017-12-29 15:26:10 +11:00
Jim Warner
3e6a208ae5 top: allow more flexible approach for startup defaults
Those references below offer more detail regarding the
default startup changes beginning with version 3.3.10.

It is important to remember that all such changes were
supposed to impact only new users or users who had not
saved the personal config file (via that 'W' command).
However, I introduced a bug wherein the rcfile was not
fully honored. This gave the changes a bad reputation.

That bug was corrected in release 3.3.11 but the issue
of default startup options keeps resurfacing. And it's
clear there's no consensus on what should be included.

Our --disable-modern-top configure option is of little
help since it remains an all-or-nothing approach. What
we need is an answer offering unlimited customization.
So, this commit will provide distribution packagers or
system administrators with a much more flexible way to
set their own preferred startup default configuration.

A new rcfile is being introduced: '/etc/topdefaultrc',
whose format/content is the same as a personal rcfile.
Thus once a 'proper' enterprise configuration has been
established and saved via 'W', it can be copied to the
/etc/ directory. Thereafter, startup in the absence of
a saved rcfile will use that configuration as default.

Now if a distribution packager or system administrator
wishes to expose their users to some of top's advanced
capabilities they can do so gradually. Perhaps setting
up graph mode for summary area task and memory display
while retaining the %CPU sort could be tried. Or maybe
showing colors, but better customized for a particular
terminal emulator. Such possibilities are now endless.

[ in exploiting this new capability, i hope that the ]
[ other windows (alt display mode) aren't overlooked ]

Reference(s):
. Sep, 2014 - Not fully honoring rcfile bug discussed
https://www.freelists.org/post/procps/top-saved-rcfile-bug
. Oct, 2014 - Attempt to defend new startup defaults
https://bugzilla.redhat.com/show_bug.cgi?id=1153049
. Jul, 2015 - Forest vs. %CPU views discussion
https://gitlab.com/procps-ng/procps/issues/6
. Oct, 2017 - Question the use of --disable-modern-top
https://bugzilla.redhat.com/show_bug.cgi?id=1499410
. Oct, 2017 - Forest vs. %CPU views discussion again
https://www.freelists.org/post/procps/Forest-mode-by-default-in-top-seems-a-bit-strange
. Dec, 2017 - Rehash of 3.3.10 startup defaults change
https://gitlab.com/procps-ng/procps/issues/78

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-12-23 17:41:37 +11:00
Craig Small
f9bef2b2c3 watch: Support ANSI 39,49 reset sequences
ANSI colour sequences 39 and 49 reset the foreground and background
colours respectively. This feature was missing from watch using the
colour "-c" option.

References:
 Fixes #73
 https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters
2017-12-20 22:09:41 +11:00
Jim Warner
0902221b95 NEWS: acknowledged top's multi-byte support extensions
Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-10-01 22:19:58 +11:00
Craig Small
bda18fd41c add changelog for previous 2017-09-25 09:14:00 +10:00
Jim Warner
a2ceb95e2a top: protect against the anomalous 'Mem' graph display
Until this patch, top falsely assumed that there would
always be some (small) amount of physical memory after
subtracting 'used' and 'available' from the total. But
as the issue referenced below attests, a sum of 'used'
and 'available' might exceed that total memory amount.

I'm not sure if this is a problem with our calculation
of the 'used' amount, a flaw in the kernel 'available'
algorithms or some other reason I cannot even imagine.

Anyway, this patch protects against such a contingency
through the following single line addition of new code
. if (pct_used + pct_misc > 100.0 || pct_misc < 0) ...

The check for less than zero is not actually necessary
as long as the source numbers remain unsigned. However
should they ever become signed, we'll have protection.

[ Most of the changes in this commit simply separate ]
[ a variable's definition from its associated logic. ]

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-08-19 20:55:46 +10:00
Jim Warner
e3c729adfa top: address a Debian wishlist NLS man page suggestion
Reference(s):
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=865689

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-08-19 20:55:46 +10:00
Jim Warner
2c88d03e7b NEWS: add issue and bugzilla references where possible
And we repositioned the kill line (Debian #854407) for
alphabetic integrity and conformance with newlib NEWS.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-08-19 20:55:46 +10:00
Jan Rybar
d9c4b6b011 top: refresh interval accepts non-locale decimal value
For the past 3 years top has fully honored that locale
LC_NUMERIC setting which impacts his refresh interval.
For the past nearly 5 years top has saved that refresh
value in a locale independent form in his config file.

With this commit we'll intentionally break top so that
a comma or period will be accepted for the radix point
regardless of what that LC_NUMERIC may have suggested.

The current locale LC_NUMERIC will, however, determine
how the delay interval is displayed in the 'd' prompt.

[ This position is better than the approach employed ]
[ by those coreutils 'sleep' and 'timeout' programs. ]
[ Both claim to permit floating point arguments. But ]
[ neither one will accept the comma separator should ]
[ the locale be a country that in fact uses a comma. ]

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

Prototyped by: Jan Rybar <jrybar@redhat.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-08-14 22:13:28 +10:00
Jim Warner
c409f5a433 top: address the argument parsing quirk involving '-h'
There exists the possibility that a 'putp' call can be
issued before the 'setupterm' invocation has occurred,
as is reflected in a bugzilla report referenced below.

Strangely, such a SEGV isn't always triggered as logic
would suggest it ought to be. I experienced a fault in
these environments with the associated curses version:
. archlinux, procps-ng 3.3.12, ncurses 6.0.20170429
. fedora-25, procps-ng 3.3.10, ncurses 6.0.20160709
. opensuse-42.2, procps-ng 3.3.9, ncurses 5.9.20140201
. gentoo, procps-ng 3.3.12, ncurses 6.0.20150808
. slackw-14.2, procps-ng 3.3.12, ncurses 6.0.20160910

Whereas under these environments there was no problem:
. ubuntu-17.04, procps-ng 3.3.12, ncurses 6.0.20160625
. debian-test, procps-ng 3.3.12, ncurses 6.0.20161126
. mageia-5.1, procps-ng 3.3.9, ncurses 5.9.20140323

[ as an aside, the expected result in the bug report ]
[ is incorrect and should mention the '1' parameter. ]

[ however, until release 3.3.13 when the '1' becomes ]
[ a valid switch, numbers are not detected when used ]
[ with any switch which doesn't require an argument. ]

[ you're welcome to treat that as a separate bugglet ]

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-05-22 21:34:38 +10:00
Jim Warner
292bd233f2 NEWS: update/alphabetize enhancements for next release
Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-05-22 21:34:32 +10:00
Jim Warner
89db82d143 top: provide -1 command line switch as 'Cpu(s)' toggle
If built without ./configure --disable-modern-top, the
program displays each cpu individually providing there
is sufficient vertical screen real estate. For massive
SMP environments this will necessitate use of a config
file where the cpu summary toggle ('1') could be saved
via the 'W' command. But, an rcfile may not be viable.

So this commit introduces a '1' command line switch to
emulate exactly the effects of the interactive toggle.

And since it is our first numeric switch some existing
parsing logic had to be changed slightly. Such changes
are, in truth, an improvement. For example, instead of
seeing "inappropriate '2'" with ./top -2 we'll now see
the vastly more appropriate error "unknown option '2'.

References(s):
https://gitlab.com/procps-ng/procps/issues/55

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 21:59:53 +11:00
Jim Warner
fb48b5d9fb top: provide -E command line switch for memory scaling
In their 3.2.7 version of top, Redhat introduced an -M
switch to automatically scale Summary Area memory data
to avoid truncation (and the resulting '+' indicator).

The procps-ng top does not employ suffixes with memory
data nor does it allow for different scaling with each
separate value. Rather, scaling appears at line start.

If built without ./configure --disable-modern-top, the
Summary Area memory will be scaled at GiB which should
lessen chance of truncation. Otherwise KiB was used to
reflect such memory, increasing the truncation chance.

And while 'W' can be used to preserve some appropriate
scaling value, there are arguments against such rcfile
approaches as cited in the issue and bug report below.

So this commit will bump the Summary Area memory scale
factor from KiB to MiB when using --disable-modern-top
as a concession to that Redhat bug report noted below.

And it also introduces a new command line switch which
can force any desired scaling regardless of the rcfile
or which ./configure option might have been specified.

[ for top's help text we'll show 'E' as if it were a ]
[ switch without arguments in order to keep the help ]
[ text displayable without wrap in an 80x24 terminal ]

[ the man page, however, will show all k-e arguments ]

Reference(s):
https://gitlab.com/procps-ng/procps/issues/53
https://bugzilla.redhat.com/show_bug.cgi?id=1034466

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 21:59:53 +11:00
Jim Warner
fe6e03d8a9 top: show fewer decimal places for memory (by default)
After much reflection I've come to the conclusion that
displaying 3 decimal places (usually) when memory data
had been scaled is no longer optimal with today's ever
increasing amounts. And given that not all task memory
fields are the same widths, inconsistencies can easily
arise as illustrated and discussed in the issue below.

Instead of unilaterally reducing the number of decimal
places, this commit will sneak in such a change via an
existing configure option that was very likely unused.

The former 'disable-wide-memory' option has now become
'enable-wide-memory', which can be used if the current
behavior (3 decimal places) is preferred. Without that
option, whenever memory is scaled beyond KiB, just one
decimal place will be shown in Summary and Task areas.

And Task area field width will no longer be changed by
this revised configure option. Instead, all such field
widths will now be fixed at the former maximum values.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 21:59:53 +11:00
Craig Small
536cea324b kill: -l space between name parses correctly
kill -lHUP would work correctly, but kill -l HUP would not.

The list option in kill was hit by a quirk of getopt_long where an
option with an optional argument would not attempt to get the argument
beyond the space, even though a mandatory argument would do that.

The fix is a kludge to scan to the next argument and if it looks
like something we can use, use it. Lucky for us, the list option is
one where parsing can stop immediately.

Thanks to Brian Vandenberg for the way forward.

References:
 http://stackoverflow.com/questions/1052746/getopt-does-not-parse-optional-arguments-to-parameters
 https://bugs.debian.org/854407
2017-02-07 22:05:18 +11:00