Just to see if I could, the new #define will force the
indentation of a parent task to be reset to zero while
maintaining the proper child indentation relationship.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Sometimes, it might be useful to isolate a parent task
and its forked children from other system activity. As
an example, a user might want to examine workload in a
specific lxc container. Or maybe there is some need to
question what's happening under the same tmux session.
Since forest view mode tends to be a relatively stable
display, it will sometimes satisfy the above need. But
that mode can't currently guarantee the target process
always remains as the topmost task or even is visible.
So, this patch will enable focusing on any parent task
and keeping it as the topmost process while displaying
it and its forked children only. It then appears as if
there is no other activity in that system by virtue of
the blank lines which follow that final child process.
To implement this new feature, top's redundant 'F' key
has been repurposed. It made little sense devoting two
keys to the Fields Management screen (especially since
the key we've taken required two separate keystrokes).
[ and while we're at it, i also added punctuation to ]
[ that prologue for 'forest_display' since all other ]
[ forest functions used punctuation. And, instead of ]
[ a pointer to a proc_t he will now get a ppt index. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
In the merge request shown below, 1 too many bytes are
written to stdout thus including the terminating null.
As the cure, this commit just reduces the length by 1.
[ along the way, we will remove some unneeded braces ]
[ plus add some additional comments with attribution ]
Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/127
. original merged change
commit 0bf15c004d
Signed-off-by: Jim Warner <james.warner@comcast.net>
In the patch referenced below, 2 potential abends were
fixed both of which involved 'alternate display mode'.
The root cause of those abends was a negative value in
the 'begnext' field for other than the current window.
And while that potential is fixed for now the existing
code almost invites such problems again in the future.
So, this patch will remove any temptation to name some
other window in the 'mkVIZrow1' macro. And, since that
macro is not the only source of 'begnext' changes, the
'mkVizrowX' is being added to identify such occasions.
[ and for symmetry i've added a 'mkVIZyes' macro and ]
[ ameliorated an otherwise surreptitious assignment! ]
Reference(s):
commit 84e85611c3
Signed-off-by: Jim Warner <james.warner@comcast.net>
- Simplify control flow a bit. We don't need two loop variables, either.
- Consistently use %lld for bytes.
- Fix the base handling for human-readable output. The code used to
calculate *mebibytes* first, then scale that to the required exponent
with the selected base, which is patently wrong.
Fixes https://gitlab.com/procps-ng/procps/-/issues/133
This commit will address potential abends upon leaving
the windows help or color mapping screens and invoking
alternate display mode ('A'). It only happens if that
current window was changed with multiple 'a'/'w' keys.
So now, rather than leaving a trail of negative values
in the 'begtask' field, compliments of that win_select
function, we'll remove the mkVIZrow1 macro. Henceforth
it will be issued just once per user interaction. Thus
a promise of 'Curwin' only being impacted is restored.
[ my thanks to Vladimir Chren for reporting this bug ]
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/210https://gitlab.com/procps-ng/procps/-/merge_requests/135
Discovered by:Vladimir Chren <vladimir.chren@gmail.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
With that commit referenced below, which preserved the
'4' and + '!' toggles in the rcfile, this VER_J_RCFILE
macro was made superfluous. But, it was never removed.
Reference(s):
commit f858e563b7
Signed-off-by: Jim Warner <james.warner@comcast.net>
in include/c.h we check if HAVE___PROGNAME is defined, but the
corresponding macro for setting (or not setting) it is missing from
the configure script. This commit adds the missing macro, by
copying it from the macro in tmux.
When top calls malloc, if a signal is received, it will
call sig_endpgm to process the signal. In the bye_bye function, if the
-b option is enable, the Batch variable is set, the fputs function
will calls malloc at the same time. The malloc function is not reentrant, so
it will cause the program to crash.
Signed-off-by: Shaohua Zhan <shaohua.zhan@windriver.com>
The build system tested for the presence of po4a binary at the
install step. procps ships with translated man pages so doesn't
need po4a for install/uninstallation.
Works already in psmisc!
References:
5fab6b7ab3
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Some of the translation files did not escape the < properly leading
to po4a aborting. Also some translators are using old templates
and this merges them to the new ones.
References:
procps-ng/procps#188
Sometimes the testing sequence would leave a source tree
under procps-ng-(version) which, if update-potfiles was
run, would include these temporary files in the list, causing issues
later.
The script now explicitly ignores those temporary files.
Since this master library isn't quite as sophisticated
as the newlib version, this patch will protect against
the possibility of multibyte characters in a program's
name combined with some locale without UTF-8 encoding.
[ it is better to treat the COMMAND column length as ]
[ more than what's actually printed than to have the ]
[ line overflow & corrupt the remaining screen lines ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch is intended to bring the master branch into
closer alignment with the newlib branch functionality.
The commit shown below replaced that 'escape_str' with
'escaped_copy' so that the ps program wouldn't execute
some code twice. However, it created a problem for the
top program when the UTF-8 encoding was not available.
Unlike ps who calls the escape functions directly, top
outputs those library provided strings unaltered. That
means there is no workaround (like LANG=) when such an
encoding was unavailable. This, in turn, can lead to a
corrupted display (especially with the linux console).
Now, when a UTF-8 encoding is not available, multibyte
chars are converted to '?', reducing display problems.
[ there's still a potential problem concerning 'cmd' ]
[ should program names contain multibyte characters. ]
[ unlike that newlib branch, this string is not ever ]
[ altered with the '?' char under the master branch. ]
Reference(s);
. Dec 2020, escaoed_copy repleced most escape_str
commit eea5626bb1
Signed-off-by: Jim Warner <james.warner@comcast.net>
Now that the ps program is using 'escape_str' for most
of the library's returned strings, this patch tries to
lessen the prospects of executing that function twice.
Our newlib branch has achieved such a goal through the
elimination of nearly all escape.c code. However, here
we avoid API change by trading some 'escape_str' calls
(with wide character overhead) for a slightly extended
'escaped_copy' call (which incurs no multibyte costs).
Note: until we migrate to the newlib version, there is
a remaining call to 'escape_str' which we can't avoid.
Such code involves the 'escape_command' function call.
[ As we prepare for this new (final?) release, there ]
[ were already internal library changes that require ]
[ a new 'revision'. This patch won't impact the API! ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
When any process' command line contains multibyte utf8
characters, two separate display problems could arise.
1. If that COMMAND column is not displayed as the very
last field, then field(s) to the right are misaligned.
2. Even when last, should utf8 string length (not that
display length) exceed allowable screen width, it will
nonetheless suffer from improper premature truncation.
Number 1 is less of a concern since the cmdline column
is likely to always be the last field to be displayed,
if only to enable right and left scrolling provisions.
Number 2 is much more likely to occur, especially with
additional fields which might be shown before COMMAND.
Or, forest view child tasks can yield the same effect.
So, this commit will permit the correct utf8 multibyte
display regardless of field position or string length.
And, we'll bring top into line with the ps program for
additional fields potentially subject to utf8 display.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Form its inception (back in May of 2011), escaped_copy
has always been a flawed function. It does not operate
on 'escaped' strings but instead treats all input as a
regular string incapable of containing utf8 sequences.
As such, it should only be used for strings guaranteed
to NOT contain multibyte characters (like supgid). For
all other strings, which could contain utf8 stuff, the
correct function should have been that escape_str guy.
So this commit changes nearly every escaped_copy call.
[ note: unlike the newlib guy, the master ps program ]
[ cannot properly handle utf8 multibyte sequences in ]
[ in the recently introduced 'exe' field shown below ]
Reference(s):
. Jun 2018, introduced 'exe' field
commit b556bf5ba8
. May 2011, original escaped_copy (cmdline, cgroup)
commit 7b0fc19e9d
Signed-off-by: Jim Warner <james.warner@comcast.net>
Use NULL in format_array to indicate that the print function shall be
used also for sorting. Change sr_nop() to NULL for all fields which
don't use pr_nop() for printing.
Before the commit (note that '--sort label' has no effect: the rows
are not sorted according to label field):
$ ps -A -o command,label --sort label | grep /lib/systemd
/lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0
/lib/systemd/systemd-udevd system_u:system_r:udev_t:s0-s0:c0.c1023
/lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0
/lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0
/lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0
/lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0
/lib/systemd/systemd --user user_u:user_r:user_t:s0
/lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023
grep /lib/systemd user_u:user_r:user_t:s0
After the commit, '--sort label' works and the output is sorted:
$ ps -A -o command,label --sort label | grep /lib/systemd
/lib/systemd/systemd --user root:sysadm_r:sysadm_t:s0-s0:c0.c1023
/lib/systemd/systemd-timesy system_u:system_r:ntpd_t:s0
/lib/systemd/systemd-journa system_u:system_r:syslogd_t:s0
/lib/systemd/systemd-logind system_u:system_r:systemd_logind_t:s0
/lib/systemd/systemd-networ system_u:system_r:systemd_networkd_t:s0
/lib/systemd/systemd-resolv system_u:system_r:systemd_resolved_t:s0
/lib/systemd/systemd-udevd system_u:system_r:udev_t:s0-s0:c0.c1023
/lib/systemd/systemd --user user_u:user_r:user_t:s0
grep /lib/systemd user_u:user_r:user_t:s0
Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
This is part of !118 where @tt.rantala found a memory leak.
The other part of !118 may come later if the performance change
is significant.
References:
procps-ng/procps!118
<utmp.h> has been deprecated since 2001 in favour of <utmpx.h>.
On glibc systems, utmp is just an alias to utmpx, so there is no
functional change using one over the other.
However, on the musl libc, a library (utmps) can be used to provide
utmpx functionality - but not utmp. This means that procps either
doesn't work properly (`w` shows nothing under musl with default no-op
implementation), or fails to build (utmps provides utmpx.h but no
utmp.h).
This commit will use utmpx.h where available, which allows `w` to work
correctly with utmps and has no change on glibc systems.