Commit Graph

376 Commits

Author SHA1 Message Date
Jim Warner
a1ab8539be NEWS: update for the 'docker' containers in <pids> api
Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-12-26 20:55:24 +11:00
Jim Warner
0ffd98f652 NEWS: acknowledged separate 'disk sleep' in <pids> api
Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-12-26 20:55:24 +11:00
Jim Warner
c9b3a2ddbc NEWS: mention change to 'SCHED_CLASSSTR' in <pids> api
Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-12-26 20:55:24 +11:00
Jim Warner
d5f74ee3bc NEWS: updated with new 'ZSWAP' fields in <meminfo> api
Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-12-26 20:55:24 +11:00
Craig Small
f9927c6650 docs: Add manpage and NEWS for human slabtop
Update slabtop.1 to describe --human flag
Added NEWS entry

References:
 https://www.freelists.org/post/procps/Add-human-flag-to-slabtop
 commit c4f33bc302
2023-10-11 18:01:22 +11:00
Jim Warner
92bdeb176f NEWS: acknowledge fix for the lost tasks ps issue #304
[ and eliminate 1 decades old useless initialization ]

Reference(s):
. Sep, 2023 - fix for ps issue #304
commit 09fbd70de3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-10-05 07:28:32 +11:00
Craig Small
23491ebf40 pgrep: Add match to environment variable
prep --env=KEY=value

Matches processes that have the environment variable KEY set to
VALUE

References:
 #167

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-10-04 21:55:06 +11:00
Craig Small
3431c17d45 ps: Add environment output
Added environment output for ps, using
 ps -o environ

Default length is 31 characters, like for the other "long" fields.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-10-04 20:53:30 +11:00
Craig Small
0892f0b823 watch: Use clock_gettime where available
clock_gettime(CLOCK_MONOTONIC) is not impacted by the admin changing the
time and is always equal or more than the previous call (e.g. time never
goes backwards).

References:
 #295

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-10-04 20:32:43 +11:00
Craig Small
d59797b4cd misc: Add NEWS for previous glob commit
Added NEWS entry for sysctl glob exclude

References:
 commit 39748b78b0
 !206

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-10-04 19:54:55 +11:00
Craig Small
1c61ac2c61 w: Cache pids and other enhancements
Load and cache the pids list once like previous version of w as
re-scanning each user is time consuming.

Make sure utmpx structure is sent when not using systemd, stops
a segfault due to empty host value

Re-worked main loops as we either had branches (systemd) or two loops
(other) when just checking for username was all that was needed.

References:
 #305

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-10-04 16:35:21 +11:00
Robert Malz
bfb0eadc38 uptime: fix output on 60 seconds
When procps_uptime will return 60 seconds uptime -p will not
provide any output except "up". To stay consistent with other
time units the expected output is "up 0 minutes".

References:
 #302

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-09-21 16:45:49 +10:00
Craig Small
91ff8d9959 library: days/users when value is 0
The check for using days/users was > 0 which meant you could
get results like 0 day or 0 user. The check is now for not 1
so w prints 0 days and 0 users.

References:
 #303
2023-09-21 16:32:34 +10:00
Craig Small
79042e07fa ps: Don't crash when using short option
ps would crash with the -si or -sf options with systemd enabled.
The issue was the utmp wasn't filled in, the long option checked, the
short option did not.

Refactored the showinfo() function so instead of a branch with duplicate
prints for the items in both long and short we just branch on the items
for long output.

Also, made the function prototypes not dependendent on systemd enabled,
it was too messy that way and passing a char* NULL is not really going
to hurt anything.

References:
 #301

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-09-12 16:59:18 +10:00
Craig Small
ca004d4657 build-sys: Add systemd/elogind to w
Depending on the compiler flags, w needs to be explictly linked
to libsystemd or elogind even though libproc2 is linked to it.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-08-31 22:24:23 +10:00
Craig Small
4ddcef2fd8 NEWS: This is Version 4.0.4
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-08-31 19:54:51 +10:00
Craig Small
469b964621 library: Increment revision
There have been some internal updates, library is now 0:2:0

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-08-19 17:47:08 +10:00
Craig Small
0632609efd misc: Add NEWS for escape fix
References:
 49f92f690c
 https://bugs.debian.org/1035649
2023-08-19 17:26:04 +10:00
Craig Small
c10ba96147 ps: Add --signames to print signal names
Fields such as pending, blocked, ignored and caught would only show
an incomprehensible hexadecimal field for signals, with the
--signames option it now shows the short name.

Largely based on the work of @mcgrof

References:
 !98
 https://gitlab.com/mcgrof/sigstat

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-08-16 17:00:31 +10:00
Craig Small
11c91313c9 watch: Add compile time flag to support color
configure --enable-colorwatch will make watch run as if
the --color option is always on. Add the -C,--no-color
option to remove color.

References:
 #296

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-08-15 21:26:13 +10:00
Craig Small
0f4de1c438 misc: Add NEWS for pidof -t
Added NEWS item for previous commit to add -t option to pidof

References:
 dd9310da0b19c06382ee205f77ed211dd8ba8ccf
 !190
2023-08-15 21:04:06 +10:00
Craig Small
a7a03ba4e4 pmap: Reset totals between procs with -X or -XX
When pmap used with -X or -XX option with multiple pids, the
totals were not reset between the pids, meaning the first total
was for pid1, but second total was for pid1+pid2.

These running totals are now reset when they are printed, meaning
each total is for it's own pid only.

References:
 issue #298

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-08-15 20:52:14 +10:00
Craig Small
2c933ecba3 ps: Fix possible buffer overflow in -C option
ps allocates memory using malloc(length of arg * len of struct).
In certain strange circumstances, the arg length could be very large
and the multiplecation will overflow, allocating a small amount of
memory.

Subsequent strncpy() will then write into unallocated memory.
The fix is to use calloc. It's slower but this is a one-time
allocation. Other malloc(x * y) calls have also been replaced
by calloc(x, y)

References:
 https://www.freelists.org/post/procps/ps-buffer-overflow-CVE-20234016
 https://nvd.nist.gov/vuln/detail/CVE-2023-4016
 https://gitlab.com/procps-ng/procps/-/issues/297
 https://bugs.debian.org/1042887

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-08-10 21:22:23 +10:00
Craig Small
7a46278fce misc: Add NEWS for last two commits
References:
 merges #197 #198

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-07-30 21:37:19 +10:00
Craig Small
9fc76f7feb misc: Add NEWS for previous
References:
 commit 2eafd0a215
 !193

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-07-13 20:27:48 +10:00
Craig Small
f4eeff0b26 vmstat: Print guest time
Guest time was removed from User time but not printed. This meant
that if guest time was non-zero then the CPU numbers did not add
up to 100%

References:
 !191
 !113
 commit 2461bb5bc1

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-07-11 19:16:15 +10:00
Craig Small
cfb3c482a5 pgrep: Suppress warning if using regex
pgrep gives a warning if the match string is longer than
15 characters and there was no match. That often does not
make sense when using regex or at the very least difficult
to know when to warn users. e.g
"1234567890|123456789X" is a 21 character string but only
matching two 10 string words.

pgrep has a simple check for regex and will now suppress
that warning if that has been used.

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-06-13 16:23:35 +10:00
Jim Warner
bc688d630a library: restore the proper main thread tics valuation
The issue cited below revealed an earlier commit, also
shown below, resulted in an incorrect tics value for a
thread group leader. That change was made so the group
leader would have a proper autogroup id, not a -1 that
was shown with sibling threads which lacked that file.

So this patch will just restore pre version 4 behavior
while not upsetting LIBPROC_HIDE_KERNEL functionality.

[ this change means that when THREAD mode is active, ]
[ the autogroup id & nice values won't be available. ]
[ they were only shown for the group leaders anyway. ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/280
. Aug, 2021 - thread group leader change
commit a375262609

Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-05-31 18:25:07 +10:00
Jim Warner
dd6a99c92d NEWS: include several more changes since release 4.0.3
Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-05-31 17:49:08 +10:00
Craig Small
c8afe6ff84 w: Fix musl UT_HOSTSIZE issue
While musl has utmpx.h, their header file does not define all the
values, especially __UT_HOSTSIZE and friends. Instead it just
hard codes the sizes :/

This change will look for that definition specifically and if
not found will include utmp.h too. Checked on Alpine 3.17

musl just makes these a stub so w doesn't work anyway.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-05-07 20:27:50 +10:00
Craig Small
b31ac2dcce free: Show single line statistics
Added the -L --line option to free to show a small
set of memory statistics on a single line of 80 characters.
Largely based on the work of @Ulenrich1 and updated to
the new API.

References:
 procps-ng/procps#156

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-05-02 20:32:38 +10:00
Jim Warner
0e98e06777 NEWS: darn, I forgot to label one change as issue #272
Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-04-05 07:20:35 +10:00
Jim Warner
c2ab0adc6d NEWS: include several more changes since release 4.0.3
Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-03-26 21:08:33 +11:00
Craig Small
8c81808de0 pgrep: Use only --signal option for signal
When pgrep was used to match on signal, it makes sense to use
the same signal parsing code as pkill. Unfortunately the
"find the signal" part is a little too enthusaistic about what a
signal is, meaning

pgrep -u -42

fails because the signal becomes "42" and then there is no UID.

This is a bit sad for pkill but has been that way for a long
time. For pgrep this is new so now only the long form
pgrep --signal <X>
will work.

In addition, when using --signal if pgrep/pkill couldn't work
out what the signal was it just silently ignored it. It now
complains and aborts.

References:
 https://bugs.debian.org/1031765
 commit 866abacf88
2023-03-01 17:35:14 +11:00
Craig Small
9b2f49166b tests: Dont compare floats with ==
Comparing floats with == is bad and I should feel bad I did this.
The problem is if something is close to, but not quite the exact
same fails tests.

I have used an epsilon of 1 because we don't care about accuracy,
just that the function works well enough.

References:
 issue procps-ng/procps#271
 https://how-to.fandom.com/wiki/Howto_compare_floating_point_numbers_in_the_C_programming_language

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-03-01 17:20:42 +11:00
Craig Small
806eb270f2 NEWS: Release 4.0.3 2023-02-16 07:26:15 +11:00
Jason Cox
848be2b1e2 pgrep: make --terminal respect other criteria
In some cases the --terminal option to pgrep will cause all processes
matching the terminal to be output, even if other criteria would exclude them.
Specifically, I noticed that it overrides the --runstates option.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-01-25 20:34:21 +11:00
Qin Fandong
0a5ccbdd42 vmstat: precision issues in unitConvert()
Fix conversion errors due to precision issues in function unitConvert

For example: unitConvert(98720620) will return 98720624, not 98720620.

Because we do (unsigned long)(float)98720620 in function unitConvert
and this is wrong! We should do (unsigned long)(double)98720620 here.

Signed-off-by: Craig Small <csmall@dropbear.xyz>

References:
 procps-ng/procps!75
2023-01-18 17:02:53 +11:00
Sanskriti Sharma
68e2c0fc53 vmstat: Fixed initial si,so,bi,bo,in & cs values
In the default display option, the first line of stats output in the
above mentioned columns was incorrect.

References:
 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=668580
 procps-ng/procps!74
 procps-ng/procps#15

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-01-18 16:56:24 +11:00
Justin Gottula
8a65a304e0 watch: Fix buggy line-deletion behaviour with --no-linewrap
This change is largely based upon Justin's patch, I just moved the
reset_ansi() parts out otherwise you get strange colour reset
behaviours.

Original patch message:
I used the --no-linewrap (-w) option for the first time today, watching
some wide output that didn't quite fit in my tmux pane. Quickly I
noticed a problem: while --no-linewrap did indeed eliminate the
spillover of lines too long for the terminal "window" width, it *also*
resulted in a bunch of lines from the program output being hidden
entirely.

After some fiddling around, the exact problematic behavior appears to be
as follows:
 1. Lines which would have wrapped (more than $COLUMNS chars long) are
    handled correctly.
 2. Lines which would *not* have wrapped (shorter than $COLUMNS) are
    printed; but then the next line is *not* printed! For long sequences
    of non-wrap-length lines, you get an every-other-line-is-visible
    sort of effect.

The logic underlying the problem seems to be this: in the run_command
loop, if the x loop goes all the way to completion (meaning we've
reached the right-side edge of the window area), there's a small block
of code for --no-linewrap whose main purpose is to call find_eol, which
eats input until it hits a newline (or EOF). Clearly this is intended to
be done for lines that are too long, so that the excess characters are
discarded and the input pointer is ready to go for the subsequent line.

However, this code isn't in any way conditional on the value of eolseen!
Short/wouldn't-wrap lines will have encountered a newline character
before exhausting the entire x loop, and therefore eolseen will be true.
Long/would-wrap lines will not have encountered a newline when the x
loop is exhausted, and so eolseen will be false.

Nevertheless, find_eol is called in *both* cases. For long lines, it
does what it's meant to do. For short lines, *the newline has already
been encountered and dealt with*, and so the actual effect of find_eol
is to eat the entirety of the next line, all the way through to its
newline, such that it isn't printed at all.

References:
 procps-ng/procps!157

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-01-18 16:46:52 +11:00
Craig Small
b2bfd76b06 watch: add -r to not rexec on terminal resize
If you have the watched program doing some other thing every time its
run and you resize the window, you might get unexpected results. The
-r option lets you run only when the interval has expired.

References:
 procps-ng/procps!125
 procps-ng/procps#190
2023-01-17 20:45:48 +11:00
Craig Small
5f4074a250 watch: Pass through bell
Based upon merge request 104, closes #174

References:
 procps-ng/procps!104
 procps-ng/procps#174
2023-01-17 16:59:00 +11:00
Leonard Janis Robert König
d70879fb9c docs: Update drs description in ps.1 from top.1
References:
 procps-ng/procps!156
2023-01-15 15:37:49 +11:00
Craig Small
7b0c87f095 misc: Add NEWS for w --pids
References:
 commit 5baf1e6226
 procps-ng/procps!159
2023-01-15 15:19:38 +11:00
Craig Small
3cfe83a25c misc: Add NEWS for pgrep -H
References:
 commit 866abacf88
 procps-ng/procps!165
2023-01-15 15:11:02 +11:00
Jim Warner
1db14dafd9 top: include the '5' toggle on the primary help screen
When the p/e-cores support (via the '5' key) was added
in the patch referenced below, I intentionally omitted
that key from the top primary help screen. This seemed
appropriate since it only applied to select Intel cpus
and, besides, that screen was getting kind of crowded.

[ it remains an objective to fit on a 80x24 terminal ]

Upon reflection, I found a way to squeeze it into that
help screen and have decided to included it. Hopefully
its presence will encourage use of top's new provision
on any Intel platforms that distinguish between cores.

Reference(s):
Sep, 2022 - exploit p/e-cores provision
commit 00f5c74b1b

Signed-off-by: Jim Warner <james.warner@comcast.net>
2023-01-15 15:02:39 +11:00
Ingo Saitz
7e24816538 vmstat: Update memory statistics
vmstat <n> would update most fields, but the memory statistics
were only fetched the first time.

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2023-01-06 13:30:39 +11:00
Craig Small
dd3cb0892d ps: Correct BSD c option
procps 3.3.17 the c option changed the command/args field
to cmd but this got removed as part of newlib

Functionality is back in with a test case.

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

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2022-12-19 16:50:12 +11:00
Craig Small
f7a33746f8 skill: Restore the -p flag functionality
When the skill program was ported to the new API the code to filter
on PID, used by the -p option, was missed. It is now restored.

References:
 https://bugs.debian.org/1025915
2022-12-12 16:46:36 +11:00
Craig Small
135069f2b2 build-sys: Set library to 0:1:0
There was a bug fix in the library but no functions add/moved/changed
Revision incremented.
2022-12-05 21:04:05 +11:00