* Removed the intro comment: it's >20 years old, some things clearly no longer
hold (UNUSED, the bug in glibc, Linux ports, ...). Replaced it with some
boilerplate intro.
* Updated manual defines of missing macros (explained in comments). Removed the
EMT/STKFLT situation (ancient).
* All functions now account for SIGRTMAX.
* Placed all known non-RT signals into sigtable[]. There's no need anymore to
try hard to only keep uniquely-numbered signals in it and to make them a
complete sequence. Most kinds of updates to the signals can be accomplished
just by editing the table. All functions accomodate, there's no longer a need
for them to maintain exceptions (most of them).
* No function returns a freeable pointer.
* strtosig(): Re-write (old one didn't handle synonyms, interpreted malloc()
failure as signal not found).
* On the auxiliary, implemented a stable sort. The stability of qsort() is
unspecified.
References:
!207
* When cmd took longer than -n to complete, -p is no longer skipping sleeps to
make up for the time lost waiting for the completion(s) [BUG].
* Code cleanup, minor optimization. Moved universal routines to
strutils/fileutils.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* -d considers all columns the new char will occupy, not just the first one.
When 日a -> a日a, 日 is now highlighted (because of the change in its 2nd
column).
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* Worked around a ncurses bug of applying combining characters to the base
character preceding the target one. -d now operates on all components of
complex characters. Removes a BUG.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* Manpage:
* Reduced EXIT STATUS to 0 and other. The others were uninteresting in a
manpage and passing cmd exitcode doesn't work.
* Removed BUG about combining characters in last column. AFAICS it's gone.
* Removed BUG about -p not killing cmd when it takes too long. That can be a
new feature, but the current behavior is what a lot of people might well
expect by default.
* Re-phrased the BUG with "rapid-fire" in it. Makes it look like a fork bomb.
* Impl. mbswidth(), the strlen()/wcswidth() for multi-byte strings.
* In header printing:
* Fixed a few bugs in positioning and truncation (it's ctime()).
* For 8BIT, column widths are considered instead of mbstring lengths (not just
for the cmd).
* ENOMEM handled after asprintf().
* ctime() -> strftime() for a localized string. Left out date. Ok?
* Most of header is pre-composed for speed.
* -qN, N < 1, becomes -q1.
* When screen resizes, -q now only pauses for a turn, doesn't restart. This is
probably as much as can be done without a modification to the change-detecting
routine.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* Manpage:
* Rewrote the description of -p. It wasn't saying what -p did.
* Added COLUMNS and LINES to ENVIRONMENT.
* Refreshed EXAMPLES, moved it up to be before BUGS.
* Regression in topic branch: tabs now print properly.
* Removed output into the hijacked stdout/err following fork().
* EINTR-protected watpid()s and the release of fds to prevent leaks.
* Removed the measure taken in Debian#240989 to circumvent faulty is(w)print().
Glibc has been fixed (verified) and as it was, watch was letting all non-ASCII
non-printables into output. I'm not terribly certain about this one, but I
figure people with old glibc also have old procps.
* Ensured reading cmd output is buffered. We do a lot of getc() from it.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* Moved character printing out of run_command() and into a new function to clean
run_command() up and isolate self-contained functionality.
* Main loops in run_command() simplified greatly.
* Bugs fixed:
* -g and -q now coexist well (both apply). Formerly, "watch -g -q X" with cmd
output changing would act as "watch -q X" with cmd output not changing.
* -d highlight no longer removes color.
* -c together with -d no longer mark the entire screen as ever-changing.
* malloc() of "wcommand" in main() corrrected (sizeof(item_ptr) ->
sizeof(*item_ptr)). Also present in a commit in another merge request, but
I could no longer keep scrolling over it.
* -q counter now restarts when terminal size changes. That puts it in sync
with the lifecycle of first_screen and prevents the counter from progressing
extra fast due to the frequent restarts of the command during the resizing.
* Regression within topic branch: -g is no longer ignored.
* Larger blank areas are now drawn using dedicated ncurses routines, resulting,
I presume, in faster & cheaper operation. Not confirmed.
* Manpage:
* Changed the -x option description. The old one made it seem like it's the
same thing, only better and everyone wants it, disregarding the fact that
it behaves differently and that this difference is probably more important
than the convenience regarding quoting.
* fgrep is obsolete, in GNU grep at least.
* Made the BUG "Non-printing characters..." into a NOTE. Some common
non-printables are actually accounted for and the others would probably ruin
the day of half the people.
* Reduced the BUG "Upon terminal resize..." The screen does get repainted when
its dimensions change. The -r is intended to prevent the screen from
repainting.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* Avoid re-computing strlen(command) every time header is printed.
* Regression within topic branch: diff once again accounts for blank space.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
* Fixed bug from watch(1): "Blank lines directly after a line which ends in the
last column do not display."
* Cursor is now hidden.
* Bug from watch(1) involving missing compound characters may have been fixed as
well. I can see no issues with canonically decomposed characters in UTF-8, if
that's what it's regarding. The BUGS stays, however, until this is confirmed.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Errors fixed when --no-wrap:
* empty line following a truncated line omitted from output
* overlong line isn't truncated when the truncation should happen "in the
middle" of a wide (wcwidth) wchar
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Minor optimisations (narrower types)
Fixed indentation
minor fixes (wcwidth() only if not WEOF, wint_t accessed as *(wchar_t *)&var)
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Unfortunately the previous '0' value for USE_PROC_CTTY
meant the Cygwin specific code in the devname.c module
would always be executed. That, in turn, meant a bunch
openat errors for anyone using PIDS_TTY_NAME / NUMBER.
Signed-off-by: Jim Warner <james.warner@comcast.net>
[ 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>
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>