Commit Graph

2374 Commits

Author SHA1 Message Date
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
Todd Lewis
3c079c821a Fix user and group name to number conversion for uid/gid above 2^31. 2020-04-24 17:36:27 +10:00
Jim Warner
992217d1c0 top: updated man page and copyright dates to year 2020
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-20 22:07:43 +10:00
Jim Warner
5cb46d3533 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>
2020-04-20 22:07:43 +10:00
Craig Small
ebaa5f2823 NEWS: Add item for previous entry
Added NEWS item for pidof show worker threads patch

References:
 commit 9c3296bae9
2020-04-10 15:00:31 +10:00
Jan Rybar
6f9565b3c7 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.
2020-04-10 14:58:15 +10:00
Jim Warner
f5a6f4af6d NEWS: fix top alpha order, add 'e' command line switch
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-10 14:37:15 +10:00
Jim Warner
3a3c1604ff 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 b2bd65407a
. 12/2012, added 'e' interactive command
commit 21e550bc08
. 12/2012, added 'E' interactive command
commit bc46f67f9a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-10 14:37:15 +10:00
Jim Warner
b8f757080a ps: eliminated inadvertent trailing double semi-colons
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-10 14:37:15 +10:00
Jim Warner
11af3b2020 top: eliminate inadvertent trailing double semi-colons
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-10 14:37:15 +10:00
Craig Small
7f83a8faab NEWS: synchronise the entries 2020-04-07 19:40:35 +10:00
Craig Small
b3f7bfede6 docs: Mention stime in ps.1
References:
 procps-ng/procps#164
2020-04-07 19:38:17 +10:00
Craig Small
5da3024e4e sysctl: config directory order
Matches the systemd directory order (/run is after /etc) and
document what directories are used better.
2020-02-27 21:56:13 +11:00
Jim Warner
d28f3f28aa 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 775223a817
. original 3.3.15 validation logic
commit 085351a0ee

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-02-18 11:36:04 +11:00
Jim Warner
be31d2470b 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 90c22e64ff

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-02-18 11:36:04 +11:00
Jim Warner
1f01bd9a9f 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 7bd4f0b6d7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-01-06 09:11:20 +11:00
Jim Warner
1d73eb567c 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 e1f419737f

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-01-06 09:11:20 +11:00
Jim Warner
12b6452135 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>
2020-01-06 09:11:20 +11:00
Jim Warner
5c37e2d42d 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>
2020-01-06 09:11:20 +11:00
Jim Warner
a331659015 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>
2020-01-06 09:11:20 +11:00
Craig Small
416b91836a 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 bb96fc4295
2020-01-05 15:19:41 +11:00
Jim Warner
7ef9289ae9 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 4550e60144

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-10-27 22:27:49 +11:00
Jim Warner
8174a5c8b7 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>
2019-10-27 22:27:49 +11:00
Jim Warner
11cf6cc005 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>
2019-10-27 22:27:49 +11:00
Jim Warner
281c37d1cd 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>
2019-10-27 22:27:49 +11:00
Jim Warner
b5587b7b94 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 887bb51016

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-10-27 22:27:49 +11:00
Jim Warner
97f7c7a549 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>
2019-10-27 22:27:49 +11:00
Jim Warner
11df806a7c 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 06be33b43e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-10-27 22:27:49 +11:00
Jim Warner
e7995652be 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>
2019-09-22 07:32:03 +10:00
Jim Warner
3caa7079d6 docs: use correct units in free.1 _________ (catch up)
Reference(s):
. origina master branch commit, 5/31/18
commit c51b329a32

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-09-22 07:32:03 +10:00
Jim Warner
3860f39b3e ps: increase command name length to 64 ____ (catch up)
Reference(s):
. orginal master branch commit, 5/19/18
commit 14005a371e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-09-22 07:32:03 +10:00
Jim Warner
34a5ea71cd 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>
2019-09-22 07:32:03 +10:00
Jim Warner
90c22e64ff 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>
2019-09-22 07:32:03 +10:00
Jim Warner
33cd2ccf87 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 c3323bdb68

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-09-22 07:32:03 +10:00
Clay Baenziger
e516cf4a18 testsuite: pgrep: Provide test for matching a more than 4k command line; beware as TCL does not seem to match on strings >4k 2019-09-21 17:00:53 +10:00
Craig Small
61b627d53c 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 f9e56d3c66
    procps-ng/procps!85
2019-09-21 16:58:30 +10:00
Craig Small
012db8222e 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 73492b182d
    procps-ng/procps#141
2019-09-21 16:20:41 +10:00
Craig Small
52f112d255 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
2019-09-21 16:05:13 +10:00
Craig Small
a6c0795d49 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
2019-09-21 15:53:45 +10:00
Jim Warner
97e1264525 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>
2019-07-04 20:46:18 +10:00
Jim Warner
e6a2931c39 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:46:18 +10:00
Jim Warner
1d8d4be046 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 ee3ed4b45e
. 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>
2019-07-04 20:46:18 +10:00
Jim Warner
40883a0b85 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>
2019-07-04 20:46:18 +10:00
Jim Warner
22a3bcbd6d 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>
2019-05-16 21:23:06 +10:00
Jim Warner
f87fc7dc83 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 9ebadc1438

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-05-16 21:23:06 +10:00
Jim Warner
a9bfb186eb 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 09503dc597

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-05-16 21:23:06 +10:00
Jim Warner
30e27d48e9 misc: adapted programs impacted by header file changes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-03-26 19:55:30 +11:00