Commit Graph

167 Commits

Author SHA1 Message Date
Jim Warner
edce9ed612 top: allow setting variable width col scroll (1 vs. 8)
The Inspection feature already offered an INSP_SLIDE_1
provision. This patch now offers similar extensions to
variable width column scrolling (assuming SCROLLVAR_NO
isn't defined). Such a provision was useful during the
development of some recent library UTF-8 enhancements.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2021-01-02 15:42:10 +11:00
Jim Warner
e80b352b74 top: more useless cosemetic changes (chiefly comments)
All of these changes are self-explanatory, so I'll not
provide any more comments thus avoiding further shame.

[ everything's perfectly justified and right margins ]
[ are filled entirely, but of course it must be luck ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-08-26 21:50:20 +10:00
Jim Warner
b46af6d213 top: preserved those new '4' and '!' toggles in rcfile
This patch will address Craig's feedback regarding the
original implementation of top's two new toggles. It's
likely other users would have questioned why they were
not saved also, once they discover these new features.

And, since the minimum terminal width was just lowered
to 80 columns, the default for window #1 is also being
changed to show the individual cpu graphs two abreast.

[ assuming no '--disable-modern-top' for ./configure ]

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172
https://www.freelists.org/post/procps/two-major-changes-to-top,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-31 22:06:26 +10:00
Jim Warner
be3dcaa842 top: reduce minimum terminal width with 2 abreast mode
For the original implementation of the '4' toggle, the
minimum width was set at 165 columns. This was done to
avoid truncations when detailed cpu statistics (versus
graphs) were being displayed. Those can not be scaled.

Upon reflection, it seems more appropriate to give the
user the choice of whether or not to truncate. And, by
reducing that minimum width requirement to 80 columns,
we'll vastly expand potential use of two abreast mode.

[ we'll keep that original as '#define TOG4_NOTRUNC' ]

The patch also updates the man document appropriately.
Along the way, we will trade the potentially confusing
word 'adjacent' for the more natural 'additional' when
detailing the '!' toggle in 4b. Summary-Area-Commands.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172
https://www.freelists.org/post/procps/two-major-changes-to-top

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-31 22:06:26 +10:00
Jim Warner
2ca99a2ee4 top: adapt former PRETEND8CPUS #define as PRETEND48CPU
This patch simply allows for better testing of our two
new toggles: '4' (2 abreast) plus '!' (combined cpus).

It had previously been dropped under the newlib branch
since top no longer managed cpus. However, now that we
have those new toggles, it seemed worth the efforts to
once again re-imagine then implement such a provision.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:49:40 +10:00
Jim Warner
94d6db6b40 top: add '!' toggle for combined cpus display, program
When implementing that earlier '4' toggle, in response
to the issue referenced below, I got to thinking about
those environments with massively parallel processors.

Such environments may not benefit from the '4' toggle.

So, I decided to implement a feature that could enable
use of those '1' and/or '4' toggles no matter how many
active processors top may have ultimately encountered.

With the new '!' toggle, adjacent cpus can be combined
to any degree, represented as a single cpu group/line.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:49:40 +10:00
Jim Warner
59f5a37a24 top: add '4' toggle for 2 abreast cpu display, program
In the back of my mind, I've always wanted to enable a
two abreast cpu display. Folks with massively parallel
machines must surely have been frustrated with the '1'
toggle when Off (individual cpus in the Summary Area).

So, I'll use that recently raised issue shown below as
a justification for finally implementing this feature.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/172

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:49:40 +10:00
Jim Warner
4c336ae9e6 top: eliminate a long standing extraneous comment line
Wow, hard to believe the extraneous comment line dates
all way back to an introduction of NLS support (2011).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-05-28 19:49:40 +10:00
Jim Warner
992217d1c0 top: updated man page and copyright dates to year 2020
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-04-20 22:07:43 +10:00
Jim Warner
7ef9289ae9 top: update copyright notations & fix a man page error
Beyond the copyrights, the single oops in the man page
was introduced in the commit which is referenced below
dealing with some cleanup following that Qualys audit.

Reference(s):
. man page error introduced
commit 4550e60144

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-10-27 22:27:49 +11:00
Jim Warner
8174a5c8b7 top: whack insidious bug surrounding auto-sized fields
This patch will eliminate a bug which is unique to our
newlib branch. It's extremely rare and only happens if
a search ('L'/'&') is initiated during the period when
fields are currently being auto-sized (AUTOX_MODE on).

This bug surfaces as either all zero results for tasks
displayed or a segmentation fault, depending upon what
fields were activated. It is caused by the timing of a
call to the <pids> 'reset' function. When called after
a task refresh, but before do_key(), this bug appears.

So this patch just ensures that 'reset' will be called
after do_key() & before the tasks have been refreshed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-10-27 22:27:49 +11:00
Jim Warner
22ae537707 top: enable alternate '+' placement with collapsed pid
Currently, except for tasks that have no parents, when
a process' children are collapsed the '+' indicator is
shown in the first position within that COMMAND field.

This commit simply provides for indenting the '+' char
so it displays next to that program name/command line.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-01-03 08:06:48 +11:00
Jim Warner
59f02f19c7 top: plug a minor hole in the vertical scrolling logic
In that commit referenced below, a few edge cases were
addressed regarding vertical positioning involving any
'hidden' tasks. But, 2 additional edge cases remained.

In a running top, if the user employed 'other filters'
(o/O) or 'user filters' (u/U) proper vertical position
was not ensured. And, while this could be easily fixed
by striking the home/end or up/down arrow keys, it was
very poor etiquette to shift this burden to the users.

So, this patch plugs that gap, automating the process.

Reference(s):
commit 9d59ddc466

Signed-off-by: Jim Warner <james.warner@comcast.net>
2019-01-03 08:06:48 +11:00
Jim Warner
ab33cd1101 top: '^V' is now 'v' (collapse/expand children toggle)
Using Ctrl-V for the collapse children key now appears
as a mistake. First, it's too close to that Ctrl-C key
which would prematurely terminate top. Second, a lower
case 'v' was unused and perfectly compliments an upper
case 'V' which is used to toggle 'forest view' itself.

Reference(s):
https://gitlab.com/procps-ng/procps/issues/99

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-07-18 20:19:43 +10:00
Jim Warner
43c3afb57e top: some minor renaming, reformatting and rearranging
This commit just addresses these miscellaneous issues:
. make a few pseudo enum's just a tad more descriptive
. always use 'p' for pointers to a 'struct pids_stack'
. add just a little indent to the 'rSv' macro comments
. rearrange section dealing with new library interface
. always match order of local #undef to parent #define
. forest_begin array index usage is now more efficient

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-07-18 20:19:43 +10:00
Jim Warner
7c7903e50d top: parent total cpu includes collapsed children, pgm
Now, when a parent's children have been collapsed, the
cpu used by those unseen tasks will disappear no more.
Instead such tics will be added to the parent's total.

[ if one wished a return to the 'land of lost tics', ]
[ the '#define TREE_VCPUOFF' directive is available. ]

------------------------------------------------------
Note: With collapsible parents now displaying children
cpu usage, it will eventually be noticed the cpu stats
for the summary area and task areas often vary widely.

It's worth a reminder that for top's summary area each
individual cpu and the cpu summary is limited to 100%,
regardless of how many tics a linux kernel may export.

An individual task is limited to 100% times the number
of threads. But, in no case will cpu usage ever exceed
100% times total number of processors. Such limits are
further reduced under 'Solaris' mode ('I' toggle off).
In this mode, a task cpu usage will never exceed 100%.
These limits will now also apply to collapsed parents.

In addition to those influences, results are subjected
to kernel timer sampling anomalies and the distortions
inherent in a small sample size, made worse by smaller
delay intervals. Often there is just 1 or 2 tics for a
few tasks at smaller intervals such as: 1/10th second.

Anyway, should questions on this subject arise, a good
starting point, beyond the reminders above, is the 1st
link listed below. Those other links were derivatives.

Reference(s):
. from the kernel documentation
https://www.kernel.org/doc/Documentation/cpu-load.txt
. as mentioned in the above kernel documentation
https://lkml.org/lkml/2007/2/12/6
. from above, with many more links on the subject
https://www.boblycat.org/~malc/apc/

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-07-17 20:58:32 +10:00
Jim Warner
1801bacc0d top: exploited the newly added field 'executable path'
[ along the way we'll shorten some of the repetitive ]
[ variable width field narratives in top's man page. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:18 +10:00
Jim Warner
9d59ddc466 top: a few tweaks for those scrolling (mostly) changes
This patch just addresses some edge cases with respect
to 'unseen' tasks. Given the ability to preserve other
filters in the rcfile, it's entirely possible the very
first task(s) may not be visible at top startup. Also,
when switching between windows ('a'/'w') we should try
to always position its row #1 on some visible process.

Lastly, a window might have *NO* visible tasks at all.
Therefore, protect 'window_hlp' from an infinite loop.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:18 +10:00
Jim Warner
6aedeac667 top: normalize vertical scrolling for hidden processes
To my knowledge, nobody has ever complained about some
anomalies when scrolling vertically if tasks should be
hidden from view. This can happen with the user filter
('u/U') or other filter ('o/O') features. And although
some tasks are not shown, they still impact scrolling.

This is most apparent when that scroll coordinates msg
is on ('C') & up/down arrow keys used (vs. pgup/pgdn).

Now that we can collapse/expand forked children, there
is a potential for yet more of those hidden processes.

So this commit normalizes vertical scrolling providing
an expected behavior. In other words, the up/down keys
skip the unseen tasks to reposition on a visible task.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:18 +10:00
Jim Warner
a8dc1a6e5a top: refactor the 'scroll coordinates' message support
This patch is simply preparation for upcoming vertical
scrolling enhancements. With those changes, it will be
impossible to predict what the beginning task position
should be at the time the message is currently issued.

This patch will allow such a message to be shown after
the individual windows' tasks have all been displayed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:18 +10:00
Jim Warner
42e8abec0d top: allow collapsible forest view children, pgm logic
The issue cited below really dealt with preserving the
'Other filter' criteria in the rcfile. But as an aside
the htop 'F6' feature (collapsed children) was raised.

I took that as an implied challenge and decided to try
implementing a similar feature in top. So, this commit
will now provide a brand new forest view toggle ('^V')
which will be used to collapse/expand forked children.

[ this patch will also lead to additional patches in ]
[ support of more rational vertical scrolling, since ]
[ many more tasks might now be hidden in some window ]

Reference(s):
. where this secondary issue was raised
https://gitlab.com/procps-ng/procps/issues/99

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:18 +10:00
Jim Warner
c88ff1782c top: to prepare for collapse, move forest view support
In anticipation of a new collapsible child feature, we
will have to make some forest view variables available
to that 'keys_task()' function. This commit just moves
the forest view logic ahead of tertiary input support.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:17 +10:00
Jim Warner
35e9269bbe top: 'other filters' saved with config file, pgm logic
Well, after the rearranging and refactoring, all those
active 'other filter' entries for each window will now
be preserved in the user's configuration file via 'W'.

For raising the issue below, thanks to Marco Ippolito.

Reference(s):
https://gitlab.com/procps-ng/procps/issues/99

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:17 +10:00
Jim Warner
5e8bf3c028 top: refactored some of that 'other filtering' support
If we are to support preserving 'other filter' entries
in the rcfile, then the current logic setting up those
osel entries for a WIN_t must be shareable for startup
and when interacting with a user. So, this commit just
repositions this current code in a shareable function.

[ along the way, we give the prior guy a proper name ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:17 +10:00
Jim Warner
016f10cb93 top: reposition some of that 'other filtering' support
When we get around to saving that 'Other Filter' stuff
in the rcfile, we'll need access to the Fieldstab plus
the justify_pad() function. So this commit repositions
two 'osel' functions in anticipation of adding 1 more.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:17 +10:00
Jim Warner
8398b7d9b0 top: refactor some of that configuration files support
The 'config_file()' function was getting a little long
in the tooth, so this commit simply renames/rearranges
some stuff anticipating 'other filters' in the rcfile.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-26 21:25:17 +10:00
Jim Warner
bd7e1fb343 top: Prevent out-of-bounds writes in PUFF(). __Tweaked
This commit moves some overhead to the Batch mode path
where it's needed. And given the new 'else if' test we
can delete some now redundant logic in the other path.

Reference(s):
. original qualys patch
0117-top-Prevent-out-of-bounds-writes-in-PUFF.patch

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-09 21:35:20 +10:00
Jim Warner
4550e60144 top: Do not default to the cwd in configs_r... Tweaked
While it's only documented (so far) in commit text and
an occasional email I've tried to maintain some coding
standards primarily for reference/navigation purposes.
They also served, I felt, as useful mental challenges.

Someday I will get around to formerly documenting them
but in the meantime here are the ones for this commit:

. functions are grouped into logical (i hope) sections
. functions & sections are ordered to avoid prototypes
. function names are alphabetical within every section
. all functions & sections must be referenced in top.h

This patch just attempts to honor the above standards,
while also covering this new behavior in the man page.

[ please note that the net result of these 2 patches ]
[ is simply to avoid pathname truncations should our ]
[ limit of 1024 be exceeded. they do not have a role ]
[ in solving the 'local privilege escalation' issue. ]

[ and we can never prevent a user from setting their ]
[ HOME var to a directory writable by some attacker! ]

[ the only real protection for that CVE-2018-1122 is ]
[ those soon to be enhanced rcfile integrity checks, ]
[ achieved through several of the following patches. ]

Reference(s):
. original qualys patch
0097-top-Do-not-default-to-the-cwd-in-configs_read.patch

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-06-09 21:35:20 +10:00
Qualys Security Advisory
d099d0e5a1 0117-top: Prevent out-of-bounds writes in PUFF().
This patch prevents three problems:

1/ Because snprintf() returns "the number of characters (excluding the
terminating null byte) which would have been written to the final string
if enough space had been available", _eol may point past the end of _str
and write out-of-bounds (in Batch mode).

2/ _eol is never checked against _str, so "while (*(--_eol) == ' ');"
may point _eol below _str and write out-of-bounds (in Batch mode).

3/ Sanity-check Pseudo_row to protect the strcpy().
2018-06-09 21:35:20 +10:00
Jim Warner
2119750a51 top: change to exploit a newly added UID used at login
In addition to exploiting the login user ID provision,
the following miscellaneous changes are also included:

. unnecessary braces have been eliminated from an 'if'

. a comment with case EU_CPU: was corrected to 's_int'
and the associated block of code relocated accordingly

. case EU_CPN: wasn't shared with other enumerators so
reference to 'i' was changed to that actual enumerator

. case EU_SGN: wasn't shared with other enumerators so
reference to 'i' was changed to that actual enumerator

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-02-19 20:33:59 +11:00
Jim Warner
52f0ee2c41 top: update copyright dates in source and man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-02-19 20:33:59 +11:00
Jim Warner
603129e60a top: allow translated field headers to determine width
After wrestling with extra wide characters, supporting
languages like zh_CN, sometimes default/minimum column
widths might force a truncation of translated headers.

So, this commit explores one way that such truncations
could be avoided. It is designed so as to have minimal
impact on existing code, ultimately affecting just one
function. But it's off by default via its own #define.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-02-19 20:33:59 +11:00
Jim Warner
264790d80d top: adapt utf8 logic to support extra wide characters
Back when top was refactored to support UTF-8 encoding
it was acknowledged that languages like zh_CN were not
supported. That was because a single 'character' might
require more than a single 'column' when it's printed.

Well I've now figured out how to accommodate languages
like that. My adaptation is represented in this patch.

[ and just in case someone wishes to avoid the extra ]
[ runtime costs, a #define OFF_XTRAWIDE is included. ]

Along the way, I've cleaned up some miscellaneous code
supporting the 'Inspect' feature so that the rightmost
screen column was always used rather than being blank.

[ interestingly, my xterm & urxvt terminal emulators ]
[ are able to split extra wide characters then print ]
[ 1/2 of such graphics in the last column. the gnome ]
[ terminal emulator does not duplicate such behavior ]
[ but prints 1 extra character in same width window. ]

Reference(s):
. Sep, 2017 - original utf8 support
commit 9773c56add

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-02-12 20:58:31 +11:00
Jim Warner
55a42ae040 top: allow more flexible approach for startup defaults
Those references below offer more detail regarding the
default startup changes beginning with version 3.3.10.

It is important to remember that all such changes were
supposed to impact only new users or users who had not
saved the personal config file (via that 'W' command).
However, I introduced a bug wherein the rcfile was not
fully honored. This gave the changes a bad reputation.

That bug was corrected in release 3.3.11 but the issue
of default startup options keeps resurfacing. And it's
clear there's no consensus on what should be included.

Our --disable-modern-top configure option is of little
help since it remains an all-or-nothing approach. What
we need is an answer offering unlimited customization.
So, this commit will provide distribution packagers or
system administrators with a much more flexible way to
set their own preferred startup default configuration.

A new rcfile is being introduced: '/etc/topdefaultrc',
whose format/content is the same as a personal rcfile.
Thus once a 'proper' enterprise configuration has been
established and saved via 'W', it can be copied to the
/etc/ directory. Thereafter, startup in the absence of
a saved rcfile will use that configuration as default.

Now if a distribution packager or system administrator
wishes to expose their users to some of top's advanced
capabilities they can do so gradually. Perhaps setting
up graph mode for summary area task and memory display
while retaining the %CPU sort could be tried. Or maybe
showing colors, but better customized for a particular
terminal emulator. Such possibilities are now endless.

[ in exploiting this new capability, i hope that the ]
[ other windows (alt display mode) aren't overlooked ]

Reference(s):
. Sep, 2014 - Not fully honoring rcfile bug discussed
https://www.freelists.org/post/procps/top-saved-rcfile-bug
. Oct, 2014 - Attempt to defend new startup defaults
https://bugzilla.redhat.com/show_bug.cgi?id=1153049
. Jul, 2015 - Forest vs. %CPU views discussion
https://gitlab.com/procps-ng/procps/issues/6
. Oct, 2017 - Question the use of --disable-modern-top
https://bugzilla.redhat.com/show_bug.cgi?id=1499410
. Oct, 2017 - Forest vs. %CPU views discussion again
https://www.freelists.org/post/procps/Forest-mode-by-default-in-top-seems-a-bit-strange
. Dec, 2017 - Rehash of 3.3.10 startup defaults change
https://gitlab.com/procps-ng/procps/issues/78

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-12-23 17:44:34 +11:00
Jim Warner
e55016def5 top: when did scale_mem parm lose 'unsigned' qualifier
Well, for some strange unknown reason it happened in a
commit referenced below. But this patch reverts it and
puts this newlib scale_mem on par with the master guy.

[ a little more research reveals that it should have ]
[ been reverted in the 2nd commit shown. that's when ]
[ types were fixed after XTRA_PROCPS_DEBUG was used. ]

Reference(s):
. when 'unsigned' qualifier lost
commit 911083bf76
. when 'unsigned' qualifier not restored
commit 105058ae2d
. when XTRA_PROCPS_DEBUG validation introduced
commit e3270d463d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-10-07 09:07:17 +11:00
Jim Warner
1bc25e920a top: correct an insidious occasional truncation buglet
With the help of our Swedish translator, hopefully the
final buglet has now been vanquished in the multi-byte
translation support. This one was a real nasty bugger.

Although it didn't occur with every terminal emulator,
occasionally random text lines were being chopped off.

As it turns out, those terminals were blameless. There
were two separate places in top's show_special routine
where potential multi-byte sequences were inadequately
addressed. Solution: exploit existing utf-8 functions.

[ it also became apparent that the translation hints ]
[ in the top_nls module were deficient. so a special ]
[ caution was added regarding the final line of txt. ]

Reference(s):
https://gitlab.com/procps-ng/procps/issues/68

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-10-02 22:23:13 +11:00
Jim Warner
d2aa8009b5 top: extend utf-8 multi-byte support to users & groups
Since all the necessary utf-8 plumbing is now in place
this commit will extend multi-byte support to user and
group names. Now top will be on a par with the ps guy.

[ plus, it's also my way of showing appreciation for ]
[ all those investments silently made by translators ]

Reference(s):
https://gitlab.com/procps-ng/procps/issues/68

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-10-01 22:35:12 +11:00
Jim Warner
b8bfa17450 top: extend multi-byte support to 'Inspection' feature
The previous commit implemented multi-byte support for
the basic top user interaction and display provisions.
This commit completes multi-byte support by addressing
that 'Inspect Other Output' feature (the 'Y' command).

Few people probably exploit this very powerful feature
which allows the perusing of any file or piped output.
And even if nobody uses 'Y', someone will stumble over
it on the help screen and try it out. Assuming top was
not built with INSP_OFFDEMO defined, they'll end up on
the screen our translators have faithfully translated.

Without this patch, such a screen would display with a
bunch of 'unprintable' characters which will then show
in the standard (less-like) way as: '^A', '<C3>', etc.
In other words, those poor screens will be a big mess!

[ this program can even display an executable binary ]
[ while at that same time supporting Find/Find Next. ]
[ imagine, a file with no guarantee of real strings! ]
[ just try a Find using less with such binary files. ]

With this commit, the translated 'Y' demo screens will
now be properly shown, providing no invalid multi-byte
characters have been detected. Should that be the case
then they'll be displayed in that less-like way above.

And, if users go on to fully exploit this 'Y' command,
there is a good chance that a file or pipe might yield
output in a utf-8 multi-byte form. Should that be true
such output will thus be handled appropriately by top.

[ in many respects, this change was more challenging ]
[ than the basic support within the previous commit. ]
[ story of my life: least used = most effort needed. ]

Many thanks to our procps-ng translators which enabled
a proper test of these changed 'Y' command provisions:
. Vietnamese: Trần Ngọc Quân
. Polish: Jakub Bogusz
. German: Mario Blättermann
. French: Frédéric Marchal, Stéphane Aulery

[ and my sincerest apologies too, for my negligence! ]

Reference(s):
https://gitlab.com/procps-ng/procps/issues/68

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-10-01 22:25:18 +11:00
Jim Warner
9773c56add top: refactored for correct multi-byte string handling
When this project first began implementing translation
support nearly 6 years ago, we overcame many 'gettext'
obstacles and limitations.  And, of course, there were
not any actual translations at the time so our testing
was quite limited plus, in many cases, only simulated.

None of that, however, can justify or excuse the total
lack of attention to top's approach to NLS, especially
since some actual translations have existed for years.

When the issue referenced below was raised, I suffered
immediate feelings of anxiety, doubt and pending doom.
This was mostly because top strives to avoid line wrap
at all costs and that did not bode well for multi-byte
translated strings, using several bytes per character.

I was also concerned over possible performance impact,
assuming it was even possible to properly handle utf8.

But, after wrestling with the problem for several days
those initial feelings have now been replaced by guilt
over any trouble I initially caused those translators.

One can only imagine how frustrating it must have been
after the translation effort to then see top display a
misaligned column header and fields management page or
truncated screens like those of help or color mapping.
------------------------------------------------------

Ok, with that off my chest let's review these changes,
now that top properly handles UTF8 multi-byte strings.

. Performance - virtually all of this newly added cost
for multi-byte support is incurred during interactions
with the user. So, performance is not really an issue.

The one occasion when performance is impacted is found
during 'summary_show()' processing, due to an addition
of one new call to 'utf8_delta()' in 'show_special()'.

. Extra Wide Characters - I have not yet and may never
figure out a way to support languages like zh_CN where
the characters can be wider than most other languages.

. Translated User Name - at some future point we could
implement translation of user names. But as the author
of the issue acknowledged such names are non-standard.
Thus task display still incurs no new multi-byte costs
beyond those already incurred in that escape.c module.

For raising the issue I extend my sincerest thanks to:
Göran Uddeborg

Reference(s):
https://gitlab.com/procps-ng/procps/issues/68

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-10-01 22:25:18 +11:00
Jim Warner
6002603e2c top: now includes that NUMA node field display support
Reference(s):
https://gitlab.com/procps-ng/procps/issues/58

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-05-22 21:38:10 +10:00
Jim Warner
810e1d38ab top: just update all of the copyright dates in sources
[ this patch has been adapted from the master branch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 22:08:07 +11:00
Jim Warner
835ee677d0 top: by default, show cmd line vs. cmd name at startup
All of top's display was designed to fit into an 80x24
terminal. This includes the help screens plus both the
Summary and Task Areas, assuming no saved config file.

With release 3.3.10, the startup defaults were changed
assuming ./configure --disable-modern-top wasn't used.
This was done in the hope of introducing some users to
unknown capabilities such as colors, forest view, etc.

The purpose of this commit is to coax a few more users
into possibly exploring another capability: scrolling.
We do so by tweaking the default startup display so as
to show full command lines. Now, when things no longer
fit in 80x24, horizontal scrolling might be exploited.

[ of course, this can be reversed with the -c switch ]

[ this patch has been adapted from the master branch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 22:08:07 +11:00
Jim Warner
b2bd65407a top: provide -E command line switch for memory scaling
In their 3.2.7 version of top, Redhat introduced an -M
switch to automatically scale Summary Area memory data
to avoid truncation (and the resulting '+' indicator).

The procps-ng top does not employ suffixes with memory
data nor does it allow for different scaling with each
separate value. Rather, scaling appears at line start.

If built without ./configure --disable-modern-top, the
Summary Area memory will be scaled at GiB which should
lessen chance of truncation. Otherwise KiB was used to
reflect such memory, increasing the truncation chance.

And while 'W' can be used to preserve some appropriate
scaling value, there are arguments against such rcfile
approaches as cited in the issue and bug report below.

So this commit will bump the Summary Area memory scale
factor from KiB to MiB when using --disable-modern-top
as a concession to that Redhat bug report noted below.

And it also introduces a new command line switch which
can force any desired scaling regardless of the rcfile
or which ./configure option might have been specified.

[ for top's help text we'll show 'E' as if it were a ]
[ switch without arguments in order to keep the help ]
[ text displayable without wrap in an 80x24 terminal ]

[ the man page, however, will show all k-e arguments ]

Reference(s):
https://gitlab.com/procps-ng/procps/issues/53
https://bugzilla.redhat.com/show_bug.cgi?id=1034466

[ this patch has been adapted from the master branch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 22:08:07 +11:00
Jim Warner
f318be467b top: show fewer decimal places for memory (by default)
After much reflection I've come to the conclusion that
displaying 3 decimal places (usually) when memory data
had been scaled is no longer optimal with today's ever
increasing amounts. And given that not all task memory
fields are the same widths, inconsistencies can easily
arise as illustrated and discussed in the issue below.

Instead of unilaterally reducing the number of decimal
places, this commit will sneak in such a change via an
existing configure option that was very likely unused.

The former 'disable-wide-memory' option has now become
'enable-wide-memory', which can be used if the current
behavior (3 decimal places) is preferred. Without that
option, whenever memory is scaled beyond KiB, just one
decimal place will be shown in Summary and Task areas.

And Task area field width will no longer be changed by
this revised configure option. Instead, all such field
widths will now be fixed at the former maximum values.

Reference(s):
https://gitlab.com/procps-ng/procps/issues/50

[ this patch has been adapted from the master branch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 22:08:07 +11:00
Jim Warner
57dfe6f92c top: accumulated misc tweaks to code/comments/man page
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-12-07 22:07:00 +11:00
Jim Warner
7730bcf53d top: just cosmetic changes, absolutely no code altered
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-10-16 08:23:38 +11:00
Jim Warner
a5ec5efc9a top: remove explicit references to NUMA_DISABLE define
Since our library is responsible for NUMA support, and
since the top program already accommodates the lack of
NUMA data, there's no reason that #define NUMA_DISABLE
need be explicitly referenced in the top source files.

Ergo, this commit just eliminates all such references.
Now, top will rely only on procps_stat_reap() results.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-09-21 21:06:12 +10:00
Jim Warner
793ada6ec5 top: correct comments & code regarding sysinfo_refresh
This commit just brings some comments plus identifiers
into agreement with the current newlib implementation.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-09-11 09:31:05 +10:00
Jim Warner
d5c5051fb3 top: provide for expanded potential displayable fields
This commit provides for raising the total displayable
fields from its current 70 to 86. It also bumps the id
in an rcfile representing the version from 'i' to 'j'.

The increase in number of fields will make sharing the
rcfile with an older top, once it's saved, impossible.

These changes are being done via a #define rather than
hard coded so any such sharing will still be possible.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-08-01 20:09:18 +10:00
Jim Warner
b09014a7b6 top: share the rcfile between master & newlib branches
Since the decision was made to also add that Linux-4.5
support (was only in this newlib branch) to our master
branch, a tweak to newlib's top is necessary. In order
to share the rcfile between them, any fields unique to
a branch must appear last in it's list of enumerators.

And the troublesome field in question above is CGNAME.

It doesn't matter if a unique field is on or off, only
that it, as a higher enum/char, appear after all other
shared fields. Otherwise one risks the 'corrupt' error
message from the top without that field or the display
of the wrong column in the top with that unique field.

[ and strictly speaking, the changes under top_nls.c ]
[ were technically not really necessary. however, we ]
[ choose to maintain strict ordering via enum value. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-09 20:51:06 +10:00