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>
The systemd-sysctl version supports excludes with globs too.
Support for that was added to sysctl to match systemd.
Existing test was updated to test this behaviour.
Signed-off-by: Jacek Tomasiak <jtomasiak@arista.com>
Signed-off-by: Jacek Tomasiak <jacek.tomasiak@gmail.com>
Some test systems fail on pmap -X 1 which should exist
and not be readable. Skip the test if either of these
is not true
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
In an issue cited below the loss of tasks was revealed
whenever the --sort option is used in combination with
forest mode. One could argue against such combinations
and print an error. But we'll take an easier approach.
This patch restores the prior version 3.3.17 behavior.
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/304
Signed-off-by: Jim Warner <james.warner@comcast.net>
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>
procps_linux_version() would fail on Hurd systems as there is
/proc/sys directory. This uses the same work-around that Cygwin uses.
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>
Removed note of difference between ps aux and ps -aux. I and most other
people get the same output.
References:
https://bugs.debian.org/935106
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Added suggestions from Debian bug #894480
Added comment about --signames on signal mask fields
References:
https://bugs.debian.org/894480
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* ps/parser.c:parse_list(): Regression (2c933ecb): node->u is uninitialized at
free(node->u) when reached before node->u=xcalloc().
* ps/parser.c:parse_list(): When "arg" is very long, CVE-2023-4016 is triggered.
2c933ecb handles the multiplication issue, but there is still the possibility
of int overflow when incrementing "items".
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>
Set the proper errno if we don't have the write permission of the key or
the path is a directory. Otherwise the warning message might be misleading.
Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com>
According to parse_trailing_pids, short ps filters: 123, -123, +123
stand for PID, PGID and SID, respectively.
Signed-off-by: Grzegorz Szpetkowski <gszpetkowski@gmail.com>
__UT_NAMESIZE is undeclared in musl, which cause:
ocps/4.0.2-r0/recipe-sysroot-native= -c -o src/w.o ../procps-ng-4.0.2/src/w.c
| ../procps-ng-4.0.2/src/w.c: In function 'print_from':
| ../procps-ng-4.0.2/src/w.c:70:22: error: '__UT_HOSTSIZE' undeclared (first use in this function); did you mean 'UT_HOSTSIZE'?
| 70 | # define UT_HOSTSIZE __UT_HOSTSIZE
| | ^~~~~~~~~~~~~
| ../procps-ng-4.0.2/src/w.c:230:43: note: in expansion of macro 'UT_HOSTSIZE'
| 230 | print_display_or_interface(u->ut_host, UT_HOSTSIZE, fromlen - len);
| | ^~~~~~~~~~~
| ../procps-ng-4.0.2/src/w.c:70:22: note: each undeclared identifier is reported only once for each function it appears in
| 70 | # define UT_HOSTSIZE __UT_HOSTSIZE
| | ^~~~~~~~~~~~~
| ../procps-ng-4.0.2/src/w.c:230:43: note: in expansion of macro 'UT_HOSTSIZE'
| 230 | print_display_or_interface(u->ut_host, UT_HOSTSIZE, fromlen - len);
| | ^~~~~~~~~~~
| ../procps-ng-4.0.2/src/w.c: In function 'find_best_proc':
| ../procps-ng-4.0.2/src/w.c:72:22: error: '__UT_NAMESIZE' undeclared (first use in this function); did you mean 'UT_NAMESIZE'?
| 72 | # define UT_NAMESIZE __UT_NAMESIZE
| | ^~~~~~~~~~~~~
| ../procps-ng-4.0.2/src/w.c:391:18: note: in expansion of macro 'UT_NAMESIZE'
| 391 | char buf[UT_NAMESIZE + 1];
| | ^~~~~~~~~~~
| ../procps-ng-4.0.2/src/w.c: In function 'showinfo':
| ../procps-ng-4.0.2/src/w.c:72:22: error: '__UT_NAMESIZE' undeclared (first use in this function); did you mean 'UT_NAMESIZE'?
| 72 | # define UT_NAMESIZE __UT_NAMESIZE
The utmp format of glibc is not Y2038 safe, not even on 64bit systems.
Query logind/elogind for all required informations instead.
Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
Previously, each press of `!' led to the combining of an additional
CPU. However, we have now updated this feature to double the number of combined
CPUs with each press.
The updated example now reflects this change: with the first press of !', two
CPUs are combined and displayed as 0-1, 2-3, ...', instead of the previous
format. Additional presses of `!' continue to double the number of combined
CPUs.
[ jw note: the commit message 1st line was amended to ]
[ add the top program name and remove capitalization. ]
[ the patch itself was adjusted to avoid a fatal po4a ]
[ man document error encountered during clean builds. ]
Signed-off-by: Vishal Chourasia <vishalc@linux.ibm.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
The last time library 'escape' logic was refactored in
the patch referenced below potential problems remained
which have now surfaced. They involve those C1 control
characters especially device control strings (DCS/ST).
Such strings, if not handled by the terminal emulator,
could lead to abnormal behaviors or even some exploit.
So, this commit will now escape the multi-byte control
characters (U+0080 thru U+009f). All single byte ascii
control characters were already treated in this manner.
[ in addition, continuation bytes in utf-8 encodings ]
[ requiring two bytes or more will also be validated ]
And unlike the current code, which will escape all the
remaining non-ascii bytes when some error is detected,
this patch honors remaining valid ascii & utf-8 bytes.
Reference(s):
. Dec, 2020 - 'escape' logic' was refactored *again)
commit 649e45482f
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch was prompted by the issue referenced below.
It also places the top man page on a par with the free
man page which does a good job of documenting sources.
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/292
Signed-off-by: Jim Warner <james.warner@comcast.net>