Commit Graph

135 Commits

Author SHA1 Message Date
Jim Warner
335c070c8d top: improve the translator hint regarding field width
Reference(s):
https://www.freelists.org/post/procps/Does-COMMAND-really-have-to-be-at-most-7-characters,2

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
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
5e708c5db7 top: provide -1 command line switch as 'Cpu(s)' toggle
If built without ./configure --disable-modern-top, the
program displays each cpu individually providing there
is sufficient vertical screen real estate. For massive
SMP environments this will necessitate use of a config
file where the cpu summary toggle ('1') could be saved
via the 'W' command. But, an rcfile may not be viable.

So this commit introduces a '1' command line switch to
emulate exactly the effects of the interactive toggle.

And since it is our first numeric switch some existing
parsing logic had to be changed slightly. Such changes
are, in truth, an improvement. For example, instead of
seeing "inappropriate '2'" with ./top -2 we'll now see
the vastly more appropriate error "unknown option '2'.

References(s):
https://gitlab.com/procps-ng/procps/issues/55

[ 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
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
Jim Warner
41661e03dc top: normalize 2 former SUSE only out-of-memory fields
Now that the conditional OOMEM_ENABLE has been removed
and all users exposed to those 'out of memory' fields,
it's about time we added them to the top man document.

But before doing so, it's long past time that they are
normalized to at last remedy this kind of foolishness:

. excessive width on that oomem score itself (8 vs. 4)
. some potentially confusing names inherited from suse

Reference(s):
. removal of misguided OOMEM_ENABLE
commit 64238730fa

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-04-17 09:12:02 +10:00
Jim Warner
46458ab6b7 top: exploit new linux-4.5 resident memory enhancement
Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/status pseudo file:
 . RssAnon - size of resident anonymous memory
 . RssFile - size of resident file mappings
 . RssShmem - size of resident shared memory

This patch just represents the initial library and top
support, sharing a commit message with 2 more patches.

p.s. locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

Reference(s):
commit 1f8e41d019

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-04-14 21:03:03 +10:00
Jim Warner
3a00c7e499 top: exploit <pids> enhancement for control group name
[ but stay tuned! there is a commit coming soon that ]
[ represents a rather major internal redesign, which ]
[ was prompted by the ps and top adaptation testing. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-14 21:49:08 +11:00
Jim Warner
f7fcb33652 top: eliminate an unused error message and its support
This commit just eliminates an error message no longer
needed under that newlib <pids> interface. Plus, a few
enumerators in the header weren't in alphabetic order.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-10-05 21:28:39 +11:00
Jim Warner
64238730fa build, library & top: make OOMEM options unconditional
It was probably always wrong to have a variable length
proc_t structure. This patch takes all remaining oomem
former suse only options and makes them unconditional.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:08:18 +10:00
Jim Warner
f937ff8238 top: eliminated old kernel-2.4 & 2.5 support (man too)
The newlib informal cutoff for kernel support seems to
be around release 2.6. This commit eliminates any such
support for really old 2.4 and 2.5 kernels within top.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:07 +10:00
Jim Warner
77dc22b910 top: exploit those new library task/threads provisions
This patch adapts top to exploit the new <proc/pids.h>
interface. And it appears to have reduced top's weight
by a considerable margin. Gone were the sort callbacks
and manipulation of those library flags. Gosh, all top
needs to do now is track some enumerators of interest.

[ whoa, wait just a damn minute. it now appears some ]
[ that weight loss was solely the result of a theft. ]

[ jeeze, we turn our back for just a minute & newlib ]
[ up & steals our pids hashing logic for his history ]
[ needs. oh well, i guess life's just not that fair. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:07 +10:00
Jim Warner
cca63f2f66 top: eliminate 'user' from the inspection view headers
Since it's possible that euser name is not being shown
or the horizontal position had been scrolled past that
USER column, then part of those headers will be blank.

So it doesn't make sense to try and show the USER that
is associated with a process at all. Thus, this commit
simply removes the 'user' provision from both headers.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:00:15 +10:00
Jim Warner
9830fdf0ae top: tweak newlib interface, as more experience gained
Now that the dust is settling following an initial API
library effort, it is apparent my naming standards may
not have always been observed. This was a minor crime,
since those standards are unwritten (& not apparent?).

Basically, top has always capitalized the first letter
of global variables in an effort to distinguish global
definitions from local variables later in the program.

So this patch alters the new API variables to conform,
while also explicitly using 'context' for key structs.

Lastly, top now employs the new '#include <proc/name>'
conventions for the new/converted module header files.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:32:16 +10:00
Jim Warner
8ded6c5739 top: exploit the new library API for cpu display needs
This commit is mostly about eliminating code, now that
a library is responsible for the cpu tics maintenance.

The top program will continue to provide numa support,
without involving the library in any of those details.
[ not to mention all the 'dl' and 'stderr' numa crap ]

With this transfer of the cpu tics duty to our library
the provision associated with the CPU_ZEROTICS #define
could not initially be migrated. The commit referenced
below suggests it may have lost its importance. In any
case such logic may yet be incorporated in the future.
But for now, that #define has been completely removed.

Reference(s):
commit ee3ed4b45e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:31:16 +10:00
Jim Warner
c3fd7473c5 top: exploit the new library API for memory statistics
This commit represents the pioneering attempt at using
the concept of 'chained' library requests in an effort
to reduce function call overhead. It required exposing
no more implementation details than were already shown
through the individual calls, yet is satisfied in one.

It is just such an approach that will prove invaluable
when it comes time to access individual /proc/##/data.
Programs could 'chain' only those 'results' structures
representing their current view independent of all the
fields any such programs might be prepared to display.

Thus the standard 'read', which wouldn't apply to task
level data very well (or efficiently), can now become
a 'read_chain' whereby the former PROC_FILL flags need
can be satisfied & yield the minimum open/close calls.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-29 21:29:33 +10:00
Jim Warner
2ba7aa8b7d top: add support exploiting new library LXC containers
Reference(s):
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1424253
https://bugs.launchpad.net/ubuntu/+source/procps/+bug/1424253

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-14 15:36:06 +10:00
Jim Warner
e107f5d63b top: miscellaneous accumulated changes to program code
This commit just tweaks top in the following respects:

. for alphabetic integrity, change 'INSP_hdr...' names

. eliminate the -Wsometimes-uninitialized warning that
was found under OSX Yosemite (llvm 6.0/clang-600.0.56)

. update program 'comments' reflecting copyright dates

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-04-07 20:46:15 +10:00
Jim Warner
d310a18fc2 top: exploit new kb_main_available, make Jaromir happy
This patch will trade a former pessimistic calculation
of free physical memory for a more optimistic one that
uses the newly added kb_main_available library export.

But in case one might wish to return to the old former
method, there's a new #define that was made available.

[ the new calculation will affect graphing mode only ]

Reference(s):
http://www.freelists.org/post/procps/systemd-support-to-library,9

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-07-18 20:49:57 +02:00
Jim Warner
a7741055f1 top: add another translation hint for graphs alignment
This should be the last of this kind of crap. I'll get
to work on some means to no longer burden a translator
with lengths requirements. Ideally each word should be
allowed to stand alone and the minimum/maximum lengths
handled programmatically when our ol' top is executed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-07-07 18:43:52 +02:00
Jim Warner
c75586f523 top: eliminated unreferenced macros & an error message
Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-07-07 18:43:52 +02:00
Jim Warner
805532ac32 top: fix translation hint to preserve graphs alignment
Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-06-28 23:46:40 +10:00
Jim Warner
f7b84f45c7 top: tweak argument parsing for some locale situations
Boy I hate locale stuff. For code I thought was pretty
robust, Jaromir sure proved that it wasn't. Anyway, me
thinks this commit closes some gaps and will cause top
to behave appropriately under various locale settings.

It does *not* permit top to respond to the ',' and '.'
floating point separator without regard to the locale.
It does, however, enforce proper LC_NUMERIC responses.

Let's look on this commit as an interim solution until
Jaromir can create that proposed 'fp_decode' function.
Who knows, he might even borrow some of our mkfloat().

[ An aside: the coreutils sleep and timeout programs ]
[ claim to permit floating point arguments. However, ]
[ neither one will accept the comma separator should ]
[ the locale be a country that in fact uses a comma. ]

[ In other words, with this commit we are way ahead! ]

Reference(s):
http://www.freelists.org/post/procps/topwatch-floating-point-input
http://www.freelists.org/post/procps/topwatch-floating-point-input,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-06-25 13:58:31 +02:00
Jim Warner
41ab7f005e top: with new bar graphs, make 'b' toggle unrestricted
While the 'b' toggle remains window based (vs. global)
it should no longer require that the window be visible
and either the 'x' or 'y' toggles to be on. Previously
those requirements were intended to remind a user that
there must be something for this command to highlight.

With the introduction of graph modes (specifically the
the bar graph) the 'bold/reverse' toggle has important
implications beyond highlighting some columns or rows.

The %Cpu(s) graph and Mem portion of the memory graphs
are designed to offer a visual clue as to the separate
elements comprising them. But that separation could be
lost under some X color schemes or when top is running
without color (in monochrome mode) and the block graph
is selected. But, if the graph is then changed to bars
any separation always becomes visible whenever the 'b'
toggle is turned off. Portions then show in 'reverse'.

So from now on we'll check nothing, we'll just toggle.

[ Besides, with all the code thrown at restricting a ]
[ 'b' toggle use, it might have all been for naught. ]
[ That toggle could still be set/unset using the 'Z' ]
[ command and the color mapping screen. Geez Louise! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-06-24 20:38:30 +10:00
Jim Warner
318919094d top: rearrange Mem & Swap lines and standardize 'used'
In anticipation of upcoming memory graphing provisions
the abbreviations 'Mem' and 'Swap' are being made into
individual translatable strings in order to be reused.

Additionally, the Mem 'used' amount will now no longer
included the 'buffers' and 'cached' values. Thus, each
Mem category becomes unique. This is the approach used
by tools such as 'htop' or the gnome 'System Monitor'.

Lastly, with that change to the 'used' category it has
been repositioned after 'free' on the Mem & Swap lines
making a comparison between 'total' and 'free' easier.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-06-22 21:39:55 +10:00
Jim Warner
0caa6d6e67 top: miscellaneous accumulated changes to program code
. prevent any input recall overrun if window downsized
. adjust translation notes for true column hdr maximum

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-05-13 16:39:49 +02:00
Jim Warner
e2868da34e top: update copyright dates plus 1 preprocessor change
Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-04-28 13:46:06 +02:00
Yuri Chornoivan
2ec9f5c22e Minor i18n fixes
Minor fixes that the translator (Yuri) has found in some of the
strings. You only know how many typos and thinkos you have when
someone is trying to translate it.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-03-03 21:58:56 +11:00
Jim Warner
24f1fbd9d0 top: avoid name conflict in the next version of stdlib
Since its inception top has always used enumerators to
identify displayable fields. They've taken the form of
P_PID, etc. As it turns out, something has changed for
libc6-dev versions beyond 2.17-93 wherein 'P_PID' will
now be exposed via stdlib.h. I have not pinpointed the
exact cause but it may depend on header include order.

This patch just trades top's long standing 'P_' prefix
convention for that of 'EU_' (short for enumerator). I
cannot find *any* header under /usr/include/ currently
utilizing this particular three character combination.

And as a further safeguard top will henceforth include
'system' specific headers after the standard includes.

Reference(s):
http://www.freelists.org/post/procps/top-wont-compile-anymore

Signed-off-by: Jim Warner <james.warner@comcast.net>
2014-02-27 06:30:44 +11:00
Jim Warner
2aa0951d1b top: expand this program to include namespaces support
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-11-25 20:57:32 +11:00
Jim Warner
739effd907 top: hint that Summary Area 'cached' is Mem (not Swap)
This patch just provides a visual clue to separate the
values reported for cached Memory from other values on
the Swapped line (which is being shared due to space).

Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718670

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-30 22:08:25 +10:00
Lance Shelton
8d989c68c0 top: program code changes, enable NUMA/Node extensions
This commit extends the top Summary Area cpu states to
include information on Non-Uniform Memory Architecture
nodes. It is based upon changes originally proposed by
Lance Shelton who was instrumental in the final patch.

With this change, the user will have new commands that
will provide alternatives to the individual cpu stats:

. '2' toggles between cpu & numa node summary displays
. '3' provides node summary and related cpu statistics

These extensions required some minimal system support.
Typically, the numactl package (and maybe libnuma-dev)
are all that's needed to show a single node which owns
all the processors. Failing that, or for slightly more
variety, top also offers a #define named PRETEND_NUMA.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Lance Shelton <LShelton@fusionio.com>
2013-04-14 22:21:42 +10:00
Jim Warner
10936365de top: touch up a few miscellaneous nls related comments
Some recent nls work on that pmap program necessitated
a return to nls translation file creation for testing.

As it turns out, my skills used in pseudo-translations
had become rusty and some newer LC_MESSAGE directories
may have been introduced since last needing the topic.

This patch just updates some programmer notes to agree
with this most recent effort and for future reference!

Reference(s):
. pmap nls support
commit 0c0c543466

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-23 13:01:16 +01:00
Jim Warner
2872d24362 top: correct a sightly obsolete nls 'Translation Hint'
When the command line sort override provisions (-o/-O)
were added, the usage text was modified to keep within
an 80 column terminal but the nls hint didn't keep up.

Reference(s):
commit 407d1fc8f2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-14 12:36:47 +01:00
Jim Warner
2c2c5f5cd2 top: introduce relational operators with other filters
When I originally entertained thoughts of maybe adding
relational operators to the new 'Other Filter' feature
the programming challenges seemed just too great. Yet,
when Jaromir suggests its desirability it now suddenly
becomes a reality. Another of life's little mysteries!

At any rate what was already an extremely powerful new
feature is even better by several orders of magnitude!

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

References:
http://www.freelists.org/post/procps/top-beyond-infinity,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-06 14:37:40 +01:00
Jim Warner
5edc6fb317 top: enable other filtering via inclusion or exclusion
This change represents the extension of user filtering
based on inclusion or exclusion. However where 'U'/'u'
filtering provides an either/or choice, this extension
offers multiple choices applicable to multiple fields.

The 'inclusion' and 'exclusion' criteria can be freely
combined making a powerful tool to fine tune a display
and avoid clutter associated with uninteresting tasks.

I'm convinced it offers unimagined future flexibility!

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/top-over-the-top,22
http://www.freelists.org/post/procps/top-over-the-top,8

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-04 18:46:34 +01:00
Jim Warner
5e4bade595 top: minor refactor in preparation for other filtering
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

Thus, given those constraints/objectives, and in order
to prepare for an upcoming Other_Filter feature, a few
things had to be renamed and rearranged. Plus a couple
of other (unrelated) tweaks were made for consistency.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 270e8e7eeb
http://www.freelists.org/post/procps/PATCH-12-top-restore-terminal-state-on-exit,4

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-04 18:46:31 +01:00
Jim Warner
709785e20b top: add the field 'USED' to top's existing repertoire
After revisiting the issue of a new field, combining 2
existing fields (RES and SWAP), I've decided it indeed
makes sense. After all, with the vastly expanded field
capability and the ease of adding new fields, it would
save some precious horizontal screen real estate while
also eliminating some mental/manual user calculations.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/top-enhancements-i-hope
http://www.freelists.org/post/procps/top-regression-reports

Signed-off-by: Jim Warner <james.warner@comcast.net>

 top/top.1     |   23 ++++++++++++++---------
 top/top.c     |   14 ++++++++++++--
 top/top.h     |    6 ++++++
 top/top_nls.c |    3 +++
 4 files changed, 35 insertions(+), 11 deletions(-)
2013-03-01 14:25:31 +01:00
Jim Warner
5a27c8095e top: make field management window size error non-fatal
Reference(s):
http://www.freelists.org/post/procps/top-won-the-sigwinch-war,3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-30 10:53:49 +11:00
Jim Warner
6f25f956e7 top: a few small adjustments to reduce display flicker
This change involves the Fields Management logic only.

With user position being maintained after signals, the
previous algorithm unfortunately used Cap_clr_eos with
each iteration of the loop. The screen flicker invited
with that choice was not apparent under all emulators.

With this commit, clearing to end-of-screen has become
conditional on whether or not there was a true resize.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit ba9092ad83

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-30 10:53:49 +11:00
Jim Warner
ba9092ad83 top: preserve current screen when receiving a SIGWINCH
Prior to this commit, top has always taken the easiest
(safest?) approach when dealing with those troublesome
SIGWINCH interrupts. Whenever the user was on a screen
other than the main display, any signal received would
force an immediate exit, returning to the main screen.

With these changes, top will retain the user's current
position regardless of what screen he/she was viewing.

In support the following additional changes were made:
* the initial help screen requires an explicit end key
` not 'any other key' formerly used to request an exit
* the colors mapping screen instructions were improved
* ^Z response was made immediate, eliminating the flag
* the sigaction's SA_RESTART flag had to be eliminated
* sigprocmask logic was normailize to the bare minimum
* the POSIX.1-2004 async-signal safe functions used in
` the signal handlers were acknowledged and documented

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/unwanted-topinspect-window-enclosure-with-the-terminal-size-change

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-24 21:29:23 +11:00
Jim Warner
1da293bf59 top: accumulated miscellaneous code and comment tweaks
This commit just addresses the following minor issues:

. restored both lost end-of-job reporting capabilities
. added missing initializers to the DEF_RCFILE #define
. added 'nls_maybe' eye-catcher to the 'Scaled_sfxtab'
. removed a now superfluous 'READMINSZ' assertion test
. man document references to 'top' are more consistent

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-23 21:23:36 +11:00
Jim Warner
dec6b8ffe7 top: happy new year while incrementing copyright dates
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-23 21:23:35 +11:00
Jim Warner
6c67c8d27a top: tweak the help screen text and termcap attributes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-26 09:11:19 +11:00
Jim Warner
9236b39f32 top: add '0' toggle (zero suppress) to the help screen
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-24 08:59:57 +11:00
Jim Warner
e6cb40235e top: extend scaled summary memory range to include EiB
This commit increases the upper limit for summary area
memory scaling to 9999.999 Exbibytes. It also enhances
the man page through a helpful table for equivalences.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Reference(s):
http://www.freelists.org/post/procps/top-regression-reports
http://www.freelists.org/post/procps/top-enhancements-i-hope,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:10:12 +11:00
Jim Warner
21e550bc08 top: provide the means to adjust scaled process memory
This commit is an unrequested outgrowth of the earlier
change dealing with summary area memory field scaling.
That user selectable scaling provision is now extended
to include 6 (at present) task oriented memory fields.

The new companion 'e' (lower case) interactive command
has been added and, like the 'E' command, it can cycle
each of the currently displayed memory columns between
KiB through TiB. There are, however, some differences.

Where '+' indicates summary area truncation at a given
radix, task memory fields are automatically scaled for
their column. Thus, not all rows use the same scaling.

And, while summary area field widths were not changed,
the task memory columns were widened in order to offer
more meaningful data when the radix was increased. The
precision is automatically increased in step with each
radix: MiB displays 2 decimal places, GiB 3 and TiB 4.

To compliment that additional precision, both the %CPU
and %MEM fields were widened by 1 column and now offer
precision up to 3 decimal places. But, unique to %CPU,
widening could already have occurred due to the number
of processors in some massively parallel boxes. At any
rate, total extra width for both memory and percentage
fields could amount to twenty (precious) columns more.

So for both the memory and % fields the original width
(along with loss of precision) can be restored via new
compiler conditionals which this commit also provides.

p.s. and it will be rcfile preserved for any restarts!

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Reference(s):
http://www.freelists.org/post/procps/top-regression-reports

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:07:41 +11:00
Jim Warner
bc46f67f9a top: provide the means to adjust scaled summary memory
Earlier this year, the switch from KiB to Mib as shown
in top's summary area was postponed to those occasions
when KiB exceeded 8 digits. In hindsight that may have
moved top in the wrong direction, given the difficulty
of digesting such large numbers of digits at a glance.

This commit adds a new 'E' interactive command used to
cycle the displayed memory amounts ranging from KiB to
TiB. Thus, users can choose the radix they wish shown.

p.s. and it will be rcfile preserved for any restarts!

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Reference(s):
http://www.freelists.org/post/procps/top-regression-reports

commit 95f2201730
Author: James Cloos <cloos@jhcloos.com>
Date:   Mon Feb 6 00:00:00 2012 -0500

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:07:40 +11:00
Jim Warner
407d1fc8f2 top: provide command line sort field override switches
This commit adds two new command line switches dealing
with the potential need to automate/script the setting
of top's current sort field independent of the rcfile.

The -o (lower case) switch requires a lone valid field
name as an argument, from among the 42 currently used.
Then, it overrides the config file's Curwin->sortindx.

And since field names are now translatable, they could
diverge from those reflected in the documentation. So,
a 2nd switch of -O (upper case) is also provided which
outputs all names as translated and understood by top.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Reference(s):
Bug-Redhat: https://bugzilla.redhat.com/871844
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857,9
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857,15
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857,16

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:07:40 +11:00
Jim Warner
d747659ad8 top: follow ps lead, allow core dumps where applicable
Reference(s):
Bug-Redhat: https://bugzilla.redhat.com/871825
commit c1f10d11bc
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:07:39 +11:00
Jim Warner
73d83ec1c2 top: add pseudo type to the inspect demo '=' provision
When 'type' was added to the alternate status line for
the '=' key, the need for the demonstration 'type' was
overlooked. This commit avoids the '(null)' potential.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Reference(s);
commit 3b2b9a95e6

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:07:38 +11:00
Jim Warner
8408a44e79 top: correct an inspect spelling error with nls impact
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-11 22:54:25 +11:00
Jim Warner
5a0614e452 top: provide inspect selections with separate searches
This commit extends Inspect provisions for 'find/next'
to each individual selection. Thus a user can maintain
multiple active searches without having to reissue the
locate command whenever the current selection changes.

To emphasize this feature the View screen now displays
the current active locate string or 'N/A' if inactive.
Such a reminder is important when no found matches are
present on the 1st display page, given that they would
otherwise be apparent via the additional highlighting.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-10 09:29:28 +11:00
Jim Warner
8292f7b8ec top: generalize handling of questionable rcfile issues
Previously top would warn users if an older version of
an rcfile was about to be overwritten. That's assuming
that RCFILE_NOERR was not defined. This left, however,
other potential rcfile issues or questions unattended.

For example, if a faulty 'inspect' redirected echo had
overwritten all window entries or if the inspect entry
was not 'pipe' or 'file' (actually, just a 'p' or 'f')
then top would silently accept it but look no further.

With this commit top will try to process every inspect
entry, while preserving unrecognized entries. Plus all
other non-fatal rcfile errors will now alert a user to
the potential overwrite when the 'W' command is given.

(now that we know a '.' + 2 spaces is squeezed to one)
(everything's perfectly justified, but it's just luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-10 09:29:27 +11:00
Jim Warner
d2c84c6e13 top: use the type size_t more consistently for inspect
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-02 13:39:52 +11:00
Jim Warner
081fe506f3 top: add a flexible 'Inspect' capability
This commit introduces an extremely powerful, flexible
brand new capability.  Now, users can pause the normal
iterative display and inspect the contents of any file
or output from any script, command, or even pipelines.

It's invoked via the 'Y' interactive command which, in
turn, is supported with simple user supplied additions
as new entries in the top personal configuration file.

A separate new 'Inspect' window supports scrolling and
searching, similar to the main top display.  Except it
extends existing 'L'/'&' (locate/locate-next) commands
so that an out-of-view match automatically adjusts the
horizontal position bringing such data into view.  And
it provides for multiple successive same line matches.

Also, the basic 'more/less' navigation keys are active
in this new 'Inspect' window, to ease user transition.

There are no program changes required when entries are
added to or deleted from the rcfile.  And there are no
known limits to the complexity of a script, command or
pipeline, other than the unidirectional nature imposed
by the 'popen' function call which top cannot violate.

Since it's impossible to predict exactly what contents
will be generated, top treats all output as raw binary
data.  Any control characters display in '^C' notation
while all other unprintable characters show as '<AB>'.

The biggest problem encountered was with the find/next
capability since that strstr guy was really diminished
given the possibility that numerous 'strings' could be
encountered *within* many of top's raw, binary 'rows'.

Oh, and another problem was in maintaining the perfect
left & right text justification of this commit message
along with all of the commit summaries.  Some of those
summaries (like this very one) are of course, slightly
shorter, to make room for the 'man document' addition.

Enjoy!

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:02 +11:00
Jim Warner
39f4067c66 top: kill/nice provide for a default pid
As an aid to the above 2 commands, and as a prelude to
an upcoming 'inspect other output' capability, the act
of selecting a process for either has been simplified.

Positioning a task as the first one displayed, via the
up/down arrow keys, will now establish it as a default
selection for the appropriate command.  Thus, that pid
will then be incorporated in a subsequent input prompt.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:01 +11:00
Jim Warner
35cd340002 top: 'X' command offers auto option
The recent introduction of a column widths override
(the 'X' command) provided for a user input amount
to be added to default field size which ranged from
5 to 10 bytes.

While that approach could prevent truncated data, the
different default sizes would almost certainly mean
some precious screen real estate was waisted.

This commit introduces the concept of dynamic widths
where top will add only enough to a field default to
prevent truncation for that specific field.

Now users have a choice between their explicit width
override or a width chosen by top to exactly match
display needs.  The former is immediate but likely
wastes some horizontal space while the latter is
iterative but will be sized precisely.

Original 'X' Command:
commit 384afa494a
commit 47e1d063ac

Extensions to 'X' Command:
commit bbf8e44fb4
commit 7557f3f754

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:13:13 +11:00
Jim Warner
384afa494a top: optional wider non-scalable cols
This commit accommodates those fields which may have
suffered truncation due to these default limits:
  . 5 digits for uid/gid type fields
  . 8 characters for user/group type fields

With a new interactive command, users can increase the
width of all such fields, or return to the defaults.

Note:
   There are no restrictions on the amount added to
   the defaults.  The user is free to vastly exceed
   screen limits which simply means such fields can
   never be displayed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
c07be1d492 top: column alignment under user control
This commit affords user control over justification
for both column headings and the subordinate data.

Separate toggles are provided for control of numeric
data and string data.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
0f61354bf7 top: refactoring now allows column header nls support
Now that column headings are independent of column
data format and require no carefully managed padding
bytes they are candidates for nls translation.

This commit migrates all column headings to the .pot
file with additional translator guidance in the form
of maximum sizes to avoid truncation.

It also places these new additions adjacent to their
associated descriptions, which were already present.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
d9cf59a9b2 top: add major/minor page fault deltas
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:37:29 +10:00
Jim Warner
17e0eaf0f3 top: add new scrollable column ENVIRON
The recent introduction of scrollable variable width
columns makes a process 'environment' a potentially
useful addition to top's displayable fields.

This commit exploits the following new library flag:
   PROC_EDITENVRCVT

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:35:24 +10:00
Jim Warner
fbfaa868ba top: improve scroll coordinates message handling
With the introduction of intra-column scrolling, the
scroll coordinates message was enhanced to give some
hint of positioning within a scrolled column.

Rather than rebuild this somewhat costly string from
scratch with each frame, we'll now do the bulk of the
work only when column headers are constructed.

The only remaining per frame costs will then be the
addition of a few terminfo escapes and the current
Frame_maxtask count.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:28:53 +10:00
Jim Warner
421b08a4df all: fix misspellings in docs and program comments
We might as well join the coreutils and util-linux
projects in correcting our own typos.

The following was left unchanged:
   top/top.c[1797]: thru -> "through"

references:
http://lists.gnu.org/archive/html/coreutils/2012-04/msg00057.html
http://marc.info/?l=util-linux-ng&m=133518057419736&w=2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-04-25 13:46:02 +10:00
Jim Warner
2fc3f15770 top: refer to memory using strict IEC standard names
Admittedly, top referred to memory quantities in
a variety of non-standard ways.  This commit brings
the program and supporting documentation into strict
compliance with IEC standard binary names.

According to wikipedia, as of 2012 this IEC standard
was still not in widespread use.  However, I'm making
this change now for the anal-retentive among us.

Reference:
http://en.wikipedia.org/wiki/Megabyte

Reported by: Roman Mamedov <rm@romanrm.ru>
Bug-Debian:  http://bugs.debian.org/662786

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-09 06:56:06 +11:00
Jim Warner
4b98733132 top: honor the restrictive, crufty old top rcfile
At one time, new top silently defaulted when an rcfile
was found to be incompatible.  This is exactly what
the old top did.  However, after some discussion it
was decided top should alert the user and thereby
save the system administrator some headaches.

Now, some are upset over the fatal error, proving you
can't please everybody.  But in all fairness, given
the difficulty of customizing old top, any reluctance
to delete an old saved rcfile is understandable.

To ease transition to this new top, old style rcfiles
will now be honored and converted to the new format.
And if not disabled at ./configure time via CFLAGS,
a user will be warned when an old style rcfile is
about to be overwritten using the 'W' command.

Lastly, the config validation logic was enhanced to
help ensure both types of rcfile haven't been edited
manually and possibly made unuseable.

Reported-By: sergio <mailbox@sergio.spb.ru>
Bug-Debian:  http://bugs.debian.org/651213

Reported-By: martin f krafft <madduck@debian.org>
Bug-Debian:  http://bugs.debian.org/651863

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-02 21:29:43 +11:00
Jim Warner
a096fec8c0 top: extend the Copyright (c) dates to include 2012
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-12 21:52:23 +11:00
Jim Warner
b246af9cec top: force newline for unexpected signal abnormal exit
This commit just restores the pre-nls behavior, which was lost
in the migration to nls string tables support.
2012-01-14 00:04:46 +11:00
Jim Warner
c465dca573 top: adapt 'locate/find next' search capability for nls 2011-12-22 23:48:06 +11:00
Jim Warner
db88a8d242 top: streamlined creation of nls string tables
The gettext documentation leads one to believe that
a printf type call is necessary for gettext string
extraction.  That turns out to be misleading and
all one really needs is the runtime gettext string
address resolution.

Thus, we can avoid our original snprintf/strdup
overhead and establish an address for the original
or translated string just by issuing the _() macro.

We create these nls string tables so that:
  1) top avoids the overhead of repeated
     runtime function calls
  2) we can control the order of top's
     strings in the .pot file
  3) translator comments don't obscure
     and clutter the main program
2011-12-22 23:48:05 +11:00
Jim Warner
7c4014f881 top: corrected typos and clarified 'Translation' notes 2011-12-22 23:48:05 +11:00
Jim Warner
3e6d1c4ee0 top: added <stdlib.h> for VALIDATE_NLS which requires exit() 2011-12-22 23:48:05 +11:00
Jim Warner
04e3ec75dd top: idiot! sometimes nls was misspelled nsl (but not anymore) 2011-12-22 23:48:05 +11:00
Jim Warner
bc441a67ea top: added additional xgettext strings plus translator hints 2011-12-22 23:48:05 +11:00
Jim Warner
de3ed5bff8 top: adapted/generalized comments for Makevars --add-comments= 2011-12-22 23:48:05 +11:00
Jim Warner
67034a9a4a top: finalized nls translation implementation 2011-12-22 23:48:05 +11:00
Jim Warner
acd73a1365 top: provided for nls table integrity validation 2011-12-22 23:48:05 +11:00
Jim Warner
da35f4a364 top: tweaked some xgettext emitted comments 2011-12-22 23:48:04 +11:00
Jim Warner
617d46633e top: redesign Uniq_nlstab/show_special (nls quirks)
Until this patch, top had used some strings with
special escape sequences to produce colors, normal
text, bold text, etc.  They took the following form,
explained by an excerpt from program comments:
  ...
  Our special formatting consists of:
     "some text <_delimiter_> some more text <_delimiter_>...\n"
  Where <_delimiter_> is a single byte in the range of:
     \001 through \010  (in decimalizee, 1 - 8)
  and is used to select an 'attribute' from a capabilities table
  which is then applied to the *preceding* substring.
  ...

Unfortunately, these nonprinting values revealed
insurmountable inconsistencies in both the front-end
and back-end translation tools.

The xgettext (extraction) program would take those
special escapes, convert them and then output raw
binary values.  Thus the .pot file would contain
lots of unprintable stuff making it unreadable.

If the following was added to po/Makevars, most of
those special escapes would be preserved in their
escape notation:
  XGETTEXT_OPTIONS = ... --escape
But two escapes were converted from octal notation
and there was no way to prevent it:
  \007  -->  \a
  \010  -->  \b

After a pass through the msginit program, most of
the escapes were reconverted to raw binary values
making translation impossible.  There was no
"--escape" option for the back-end programs like
there was for xgettext.

But the real killer was the escape \004, also used
in some of top's special strings.  This value would
be silently accepted by xgettext, only to produce
the following fatal error in back-end programs like
msginit, msgfmt and msgen:
  .pot:2647: context separator <EOT> within string

To quote from one of the references below:
  "Would you create a suite of tools that silently
   allow what is destined to become a fatal error
   to pass unnoticed?"

So the bottom line was: top's special strings, in
use for the past nine years, had to be redesigned.

References:
http://www.freelists.org/post/procps/procpsng-nls-support,11
http://www.freelists.org/post/procps/procpsng-nls-support,14
2011-12-22 23:48:04 +11:00
Jim Warner
5826ce4c6e top: relocated nls.h from top_nls.h to top_nls.c 2011-12-22 23:48:04 +11:00
Jim Warner
3f7468082a top: finalized top nls support (or so he thought)
summary of changes:
. adopted relative paths to 'include' and 'proc'
  dirs so that stand alone compiles are made
  easier and no one need guess their locations

. corrected several names for enums and macro
  usage reflecting fmt vs. txt

. expanded all octal escape sequences to a full
  3 digits since one already required 3 digits

. finalized translator hints (for now)

programming note:
  as an aside, by not including an argument for
  the gettext --add-comments, any preceeding c
  style comment will be propagated to the .pot
  file, if the gettext macro isn't empty.

  /* Need Not Say 'TRANSLATORS' ...
  snprintf(buf, sizeof(buf), "%s", _(   // unseen
  /* Translator Hint: ...
  snprintf(buf, sizeof(buf), "%s", _("" // seen
2011-12-22 23:48:04 +11:00
Jim Warner
32a9adbc13 top: provide extensive, generalized nls support
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2011-12-22 23:48:04 +11:00