[ 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>
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>
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>
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>
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>
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>
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
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>
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>
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:
!98https://gitlab.com/mcgrof/sigstat
Signed-off-by: Craig Small <csmall@dropbear.xyz>
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>
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>
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>
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>
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>
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>
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>
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
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>
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
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>
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!125procps-ng/procps#190
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>
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>
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>
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