Commit Graph

694 Commits

Author SHA1 Message Date
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
46bd0085b0 top: column alignment under user control, man document
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
64cfdda756 top: refactor and enhance column width management
This commit accomplishes the following objectives:
 * remove extra task_show parm added with 'Locate'
 * avoid column overflow with subsequent misalignment
 * eliminate spaces for column heading padding
 * decouple column headings from column data formats
 * eliminate all hardcoded column format specifiers
 * generalize the inter-column spacing management
 * remove Fieldstab.desc in favor of direct nls access
 * set the stage for nls support of column headings
 * set the stage for dynamic changes to justification

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:39 +10:00
Jim Warner
767a13b96c top: tidy up some miscellaneous user input logic
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:39 +10:00
Jim Warner
718cececc7 top: correct an old man document flaw
This flaw was revealed under 'man2htm' and dates back
to the first Gitorious revised top submission.

Reference:
commit fd62123562
Date:   Thu Mar 31 22:15:12 2011 +1100

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:39 +10:00
Jim Warner
beb0982b28 top: implement a new approach to forest view mode
The TREE_RESCANS #define (formerly TREE_ONEPASS) has
been eliminated and the approach to forest view mode
redesigned.  The chance of dangling children has been
eliminated and overhead reduced.

We now order processes on start_time (non-display)
and are therefore immune to any pid, ppid or tgid
anomalies when pid values wrap.

The new algorithm also accommodates any distortions
caused by the 3.3 kernel 'hidepid' provisions --
something guaranteed to produce dangling children
under the former approach.

Related References:
commit a2086dfdf6
commit cd608f462e
commit 41ed28aa5d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-31 07:22:31 +10:00
Jim Warner
d9890fb5ac top: add major/minor page fault deltas, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:37:37 +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
6cc7416441 top: add new scrollable column ENVIRON, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:35:33 +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
a2086dfdf6 top: revise default for forest view child scans
In an effort to avoid dangling children when in forest
view mode, top defaulted to a complete rescan of every
proc_t for each child encountered.

That expense was never really cost justified and now
with the 3.3 kernel 'hidepid' provisions it no longer
can offer such protection.

With this commit, the TREE_ONEPASS define is changed
to TREE_RESCANS so as to reverse the default scan
behavior.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:30:26 +10:00
Jim Warner
06e92e93b8 top: miscellaneous minor tweaks (mostly spelling)
This commit represents mostly spelling corrections
in comments.  It also includes a few very minor logic
changes/relocations.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:29:46 +10:00
Jim Warner
6940430c55 top: correct field order within Section 3a, man document
This section purported to list fields in alphabetical
order, but this was not always true.

With this commit, strict ascii collating sequence is
now observed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:29:34 +10:00
Jim Warner
22515ce62e top: improve unsolicited user input validation
The logic associated with invalid keystrokes was
simplified through some minor reordering.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:29:17 +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
896f3deeb9 top: add intra-column horizontal scrolling, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:28:34 +10:00
Jim Warner
a652ba8c9d top: add intra-column horizontal scrolling
This commit introduces horizontal scrolling within any
variable width column.  Thus, an entire command line,
complete list of control groups, etc. can now be
viewed -- not just a screen width's portion.

It is activated when any variable width column:
 . is (via field selection) or
 . has become (via the right arrow key)
the only displayed field.

Then, the right and left arrow keys can be used in the
normal way to continue scrolling within that column.

The amount scrolled with each key press is currently
set as the normal tab stop increment of 8 characters.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:28:18 +10:00
Jim Warner
f114476a94 top: exploit library changes to cgroup & supgid
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-08-29 17:26:54 +10:00
Jim Warner
04ca0b1cbf top: ensure /proc is mounted before term is diddled
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-04-25 15:23:22 +10:00
Jim Warner
39243fe306 top: address a defect with the library PROC_PID flag
The library does not weed out potential duplicate PID
values when sampling with the PROC_PID flag.  This was
treated as merely an inefficiency by top and safely
ignored prior to the advent of forest view mode.

Now, however, if the -p switch duplicates certain PIDs,
*and* those processes have no PPID, *and* top's forest
view mode is active or activated, then a SEGV will be
generated (and caught).

This rather obscure buglet is thus limited to pid #1
(/sbin/init) and pid #2 (kthreadd).  With any other
duplicate PIDs the worse case scenario was a '?' in
place of the usual forest view artwork.

This commit silently ignores any duplicate process ids
and thereby avoids the potential segmemtation fault.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-04-25 13:46:17 +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
Sami Kerola
47100a8125 docs: fix manual page warnings
All warnings where about unnecessary quoting.  The scriptlet
below will tell what was wrong.

for I in ./top/top.1 ./ps/ps.1 ./*.[0-9]; do
    echo "== $I warnings =="
    man --warnings=all $I > /dev/null
done

This should probably be turned to 'make check' script.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-16 12:55:53 +02:00
Jim Warner
e9a9bad264 top: document an existing provision of pid monitoring
Since its inception top has provided for monitoring
only specific process ids via the -p command line
switch.  This provision has also embraced the top
process itself, even though its pid wasn't yet known.

This commit simply documents the special zero value,
which would otherwise be an invalid process id.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-04-16 08:30:06 +10:00
Craig Small
09d67d5ab2 Merge remote-tracking branch 'sami/2012wk12'
Conflicts:
	watch.c
2012-04-15 10:44:37 +10:00
Jim Warner
cd253e0dc6 top: fix a segfault when -p switch specified invalid pid
In attempting to keep at least one task visible when
scrolling vertically, a negative task index would be
produced when pid monitoring was in effect and no
matching pid was found.

Since there were already other conditions where no
task might displayed, the faulty source line has been
removed.

Bug-Debian: http://bugs.debian.org/668335

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-04-15 10:25:05 +10:00
Jim Warner
b079d130d7 top: miscellaneous cosmetic non-logic changes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-04-15 10:24:59 +10:00
Jim Warner
0c874637ee top: extend case-insensitive option to include 'Locate'
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-04-15 10:24:54 +10:00
Sami Kerola
52269d22f3 all: check stdout and stderr status at exit
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code.  The uptime is just an
example same was true with all commands of the project.

$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:53 +01:00
Jim Warner
2323f864f3 top: correct miscellaneous omission, typo and buglet
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-18 08:18:11 +11:00
Jim Warner
fa21a6ca81 top: correct loss of keystrokes paste capability
When top introduced true line input editing, the
ability to paste keystrokes was lost.  This remains
a necessary evil so that top has an opportunity to
translate cursor motion keystrokes into terminfo
escapes during line input.  Motion keys themselves,
of course, can never be pasted.

If pasting ever became more important than input
editing, then native termios support should have been
available via a define called TERMIOS_ONLY.  But a
recent commit, eliminating what was thought to be
obsolete logic, rendered the alternate linein()
function virtually useless.

Similar to top-3.2.8, when native termios input is
functional, these abberations can be experienced:
. cursor motion keys will appear as escapes
. excessive input can cause line wraps
. ^Z during i/p is not be honored until <Enter>
. SIGWINCH during i/p corrupts screen temporarily

In hindsight, it now seems that the ability to paste
keystrokes may indeed outweigh any shortcomings of
native termios support.  This is especially true if
one is preparing to search ('L') for some lengthy
process command line contined in the clipboard.

Thus, this patch fixes the alternate linein() function
and changes TERMIOS_ONLY to TERMIO_PROXY so that top
now defaults to using native termios input.  In turn,
that will restore the paste keystrokes capability.

Reference(s):
commit: 045538e01b

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-16 07:10:53 +11:00
Jim Warner
397810a67f top: some isolated typos and minor code changes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-16 07:06:53 +11: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
87bb21b557 top: fix selected miscellaneous compiler warnings
These per instance warnings have been eliminated:
warning: range expressions in switch statements are non-standard
warning: padding struct to align 'winflags'
warning: dereferencing type-punned pointer will break strict-aliasing rules

   These per instance warnings have not been addressed
   since they simply trade one warning for another:
      From:
warning: ISO C does not permit named variadic macros
warning: ISO C does not support the '%Lu' gnu_scanf format
      To:
warning: anonymous variadic macros were introduced in C99
warning: ISO C90 does not support the 'll' gnu_scanf length modifier

   Lastly, since all C compilers have supported use of
   C++ style comments for the past 20 years, the top
   program will never trade them for the often more
   cumbersome C style comments simply to avoid this
   once per source file warning:
warning: C++ style comments are not allowed in ISO C90

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-06 11:05:42 +11:00
Jaromir Capik
0f6b289212 license: update FSF addresses
The license files are synchronized with the versions from GNU web
site.

http://www.gnu.org/licenses/gpl-2.0.html
http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html

Signed-off-by: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-04 08:04:24 +11:00
Jim Warner
0053eefbb9 top: extend rcfile conversions for '--enable-oomem'
Under openSUSE, old top uses additional fields for
out-of-memory reporting.  As a result, under the
original approach to rcfile conversion, new top would
issue a fatal corrupt window entry message asking that
the rcfile be deleted.

This patch extends the conversion range to include
the extra openSUSE field characters.  It's effective
when ./configure specifies the --enable-oomem option
which in turn defines OOMEM_ENABLE.

This commit also makes the conversion logic slightly
more forgiving.  While enforcing an upper limit on the
expected number of old style field characters, amounts
less than that will be handled seemlessly.

Reference:
commit 4b98733132

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-03 14:01:35 +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
488aa10d33 top: fix a regression associated with USE_X_COLHDR
When sort column header emphasis was extended to a
monochrome screen, the ability to emphasize selections
on the Fields Management screen was lost when colors
were not being displayed.

This patch corrects that bug by using the capclr_hdr
terminfo string instead of capclr_msg.

Reference:
commit 0c6aa6af41

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-02 21:29:26 +11:00
Jim Warner
efb9fcb816 top: relocate a prototype to prevent compiler warning
Until the 'locate/search' provisions were added,
top avoided the need for any function prototypes
through careful source file organization.  But
the addition of the find_string function required
a prototpe for task_show, lest a massive file
reorganization be undertaken.

This commit moves the actual protype out of top.h
and places it adjacent to the caller in order to
avoid a warning when top_nls.c is compiled.

References:
commit 270e8e7eeb
commit d6e6a9aa38

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-28 08:45:44 +11:00
Jim Warner
4dac0dfeb1 top: isolate #defines actually present in confiure.ac
All top.h defines were lumped together as:
   'Development/Debugging defines'

This commit establishes this new category:
   'Defines represented in configure.ac'

And that new category now contains OOMEM_ENABLE,
which enables the SuSE out-of-memory additions

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-28 08:45:35 +11:00
Jim Warner
045538e01b top: remove residual logic for obsolete functionality
At one time the 'open_psdb_message' library call was
supported with the concept of a postponed message
which would display after top startup completed.
In turn, that required logic to strip the '\n' which
was embedded (inappropriately) in any such message.

Nowdays top treats such a returned error as fatal so
there is no need for the 'strim' function which is
being removed with this commit.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-28 08:45:12 +11:00
Jim Warner
ee3ed4b45e top: update latest CPU % distortions understanding
We originally approached the potential problem of
% CPU distortions as unique to Nehalem type cpus.
The latest information suggests that it may have
been due to a kernel anomaly that has since been
corrected.

Yet even without such a cpu, wide disparities in
tics allocation among all available cpus have
sometimes been observed -- spikes as it were in
the normal pattern.  This has happened under both
version 2.26.38-13 and 3.0.0-15 kernels.

The small amount of additional code addressing the
original problem carries very little overhead.  It
is being retained to afford protection against any
future tic accounting aberrations.

In this commit, supporting programmer comments have
been divorced from any particular cpu type.  Also,
another variable and manifest constant will now be
eliminated when CPU_ZEROTICS is defined.

References:
commit 02508b3d76
http://www.freelists.org/post/procps/CStates-handling-new-switch,50
2012-02-28 08:45:07 +11:00
Jim Warner
ccb5144050 top: fix regression created when fields mgmt reorg'd
When the calibrate_fields function was broken up for
mainainability, an obscure regression was introduced.

For the resulting bug to affect the display, all of
the following conditions would have to be met:
 . USE_X_COLHDR was not defined
 . column highlighting had been turned on
 . many, perhaps all, fields were displayable
 . the user then typed the <End> key
 . and the current sort column just happened to
   be immediately to the left of the left-most
   visible field

This patch corrects for that remote possibility.

Reference:
commit d0e16acf15

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-28 08:44:59 +11:00
David Cantrell
3e7f78d296 Add -p|--pretty option to uptime(1) for pretty output.
This patch adds the -p option to the uptime(1) command, which changes
the uptime displayed from something like:

 10:35:52 up  2:33,  1 user,  load average: 1.69, 1.65, 1.63

to:

 up 2 hours, 33 minutes

I originally implemented this as the up(1) program about 14 years ago.
In 2008 or 2009, I created a patch for procps to add this functionality
to uptime and submitted it to the project.  Never heard from the
project and no new releases of procps had been made.  Then I found out
about this project and decided to port my patch to it.  So here it is.

This is really just for fun.  There is no real technical reason to
have this functionality.  But even now, 14 years later, I still get
emails asking where the source code for up is.  So I thought it would
be nice for the uptime command on Linux to sport the up functionality
by default.
2012-02-22 10:35:12 -05: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
d0e16acf15 top: reorganize some fields management logic
The calibrate_fields function had grown too large and
was adversly impacting maintainence.  So half of the
logic was split out into a new function.

Now, maintainence of column headers and the required
library flags is organized as follows:

 . adj_geometry   (calibrate_fields helper)
     provides low-level support for sigwinch, memory

 . build_headers  (calibrate_fields helper)
     constructs the headers and library flags

 . calibrate_fields
     establishes which fields will be displayed

( note the alpha order mentioned in a prior commit )

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-12 21:52:23 +11:00
Jim Warner
270e8e7eeb top: standardize names of all 'helper' functions
The top program is carefully organized into sections
and those sections are carefully placed so as to avoid
the need for prototypes. *

Additionally, names of functions are carefully chosen
to maintain alphabetical order within each section.

The names of most 'helper' functions, which are always
placed immediately above the calling functions, often
only met the spirit of the alphabetical law, not the
actual letter of that law.

This commit alters the names of such helper functions
so as to mainatin strict ascii alphabetical order
within each section.

* the single exception to prototypes is find_string,
  which calls the task_show function, and would have
  prompted a massive reorganization.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-12 21:52:23 +11:00
Jim Warner
02508b3d76 top: use CPU_ZEROTICS to embrace the Nehalem logic
The recently added logic dealing with "missing" tics
is mutually exclusive with logic associated with a
define called CPU_ZEROTICS.

This commit expands the use of that define to exclude
such Nehalem logic as appropriate.

It also extends programmer notes in top.h to include
an attribution for initiating the topic of potential
Nehalem type % CPU distortions, acknowledging:
  Jaromir Capik, <jcapik@redhat.com>

References
commit ce1410a51a
commit 9e7dd43ab7
commit a9041a5526
2012-02-12 21:52:23 +11:00
James Cloos
95f2201730 top: postpone the switch from Kb to Mb in summary display
The mem and swap lines have enough room to show eight significant
digits, so switch to showing MB when >=100MB, not >=10MB.

The extra detail is valuable; it should not be elided.

Signed-off-by: James Cloos <cloos@jhcloos.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-02-12 21:52:23 +11:00
Jim Warner
ce1410a51a top: fixup logic for Nehalem cpu 'idle' threshold
Due to a poorly constructed temporary fprintf
used during development, an earlier commit went
a little too far in its computations.  The net
result was the code looked nice but actually
accomplished nothing.

It is the /proc/stat line 1 (summary line)
whose tics must be used in establishing the
threshold boundary.  And that calculation
need be performed just once per frame.

This commit ensures one threshold calculation
per delay interval no matter how many cpus
are ultimately displayed.

It also corrects scalability by factoring in
the total number of online processors.

Reference:
commit 9e7dd43ab7
2012-02-10 07:01:10 +11:00
Jim Warner
9349100dd3 top: reduce use of 'clear_screen' to absolute minimum
Along the way to width override support (-w switch),
this top began clearing the screen far more often
than his predecessor.  In fact, it happend with each
user keystroke.

This commit dramatically reduces those occurances.
The screen will now be cleared only when an actual
SIGWINCH is received.

Thanks for identifying this flaw belongs to:
James Cloos, cloos@jhcloos.com

References:
http://www.freelists.org/post/procps/Merge-request

Blame:   c2dcbef482
Author:  Jim Warner <james.warner@comcast.net>
Date:    Thu May 26 11:33:32 2011 +0200
subject: added output width/height override support to top, + misc
2012-02-08 21:00:18 +11:00
Jim Warner
9e7dd43ab7 top: tweak the new 'reduce % CPU distortions' algorithm
The original approach to potential % CPU distortion due
to Nehalem type cores being turned off completely when
idle worked ok until the user typed something.

At that point, elapsed tics would no longer equal the
calculated value producing an undesirable 100% idle
condition until the next update or <Enter/Space> key.

This commit employs actual elapsed tics in determining
whether a cpu should be considered idle and thus makes
top's individual cpu display immune to user keystrokes.
2012-02-08 21:00:00 +11:00
Jim Warner
a9041a5526 top: reduce % CPU distortions when a core was turned off
This patch provides for cpu cores which can be turned
off completely when idle (Nehalem, etc.) thus registering
very few or no tics since the last update cycle.

When CPU_ZEROTICS is not defined (the default), any
displayed cpu with less than a certain amount of total
tics will show as 100% idle.  That amount is tempered
by the delay interval and total number of cpus.

This commit also satisfies the Debian 'top_nohz' patch
(11/24/09) in a slightly more efficient manner.  That
patch concerned kernels built with CONFIG_NO_HZ.

Reference:
http://www.freelists.org/post/procps/CStates-handling-new-switch,4
2012-02-08 20:57:58 +11:00
Jim Warner
f348575edc top: tolerate loss of smp cpus, improve CPU_t management
Prior to this patch, top was able to handle any hotplugged
cpus *added* to the system in two distinct ways.

 1) Newly added cpus would be detected by sysinfo_refresh
    calling the library's cpuinfo function, which occurs
    at most every 5 minutes.

 2) The user could force a refresh using either the
    <Enter> or <Space> keys.

Unfortunately, the *loss* of a cpu would produce an early
exit due to a /proc/stat read failure.  Such a failure
can be produced in the following way:
  sudo echo 0 > /sys/devices/system/cpu/cpu??/online

This commit allows top to tolerate the loss of cpus.
It also provides for more efficient CPU_t management,
especially for massively parallel cpu environments.

Note: Changes to the cpu compliment can produce a single
cycle distortion of cpu percentages.  Such distortion is
most visible when each cpu is being displayed.  It can
be eliminated with a forced refresh via <Enter>/<Space>.
2012-02-08 20:57:51 +11:00
Jim Warner
d7c986cd30 top: treat additional keys like the find_string() keys
With the introduction of the 'locate string' provisions,
the precedent for calling tertiary helper functions from
secondary do_key helper functions was established.

This commit simply migrates some additional keys out of
the do_key function itself and into the more generalized
key table.
2012-02-08 20:57:44 +11:00
Jim Warner
0c6aa6af41 top: improve USE_X_COLHDR effect when colors toggled off
Normally, when the chosen sort column is displayed via the
'x' command toggle the entire column is highlighted.  And
while this version of top substantially reduced the cost
of such highlighting, a small pathlength increase remained.

The USE_X_COLHDR define was an experimental alternative which
eliminated all recurring runtime costs for such emphasis by
highlighting the column header, not the entire column.

The previous implementation required colors to be turned on
(the 'z' toggle) for such highlighting to be visible.  This
commit extends column header emphasis to include monochrome
displays as well.

Reference:
http://www.freelists.org/post/procps/post-nls-merge,6
2012-02-08 20:57:38 +11:00
Jim Warner
9573a6fe5b top: properly handle an improper $HOME environment variable
Since its inception, this top has improperly handled an
empty HOME environment variable.  Under those conditions
a path to the root directory would have been constructed.

That caused no real harm upon startup since the display
defaults would have been employed.  However, except for
root, it would have been impossible to save the rc file.

This commit keeps the promise made in the documentation.
2012-02-08 20:57:30 +11:00
Sami Kerola
8f7eefc9c8 docs: aligh top.1 header with other procps-ng utils
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-21 16:49:47 +01:00
Jim Warner
b73a423cc2 top: avoid %cpu distortions when toggling task/thread modes
This commit addresses a long standing buglet (debian #441166) which
surfaces when the display mode is switched between task and threads.

An extra procps refresh is now forced upon such a transition which
parallels the approach used at startup for the exact same reason.

Reference: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441166
2012-01-14 00:04:46 +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
7a64b0cd6c top: add PACKAGE and LOCALEDIR to ATEOJ_RPTSTD output 2012-01-05 09:56:05 +11:00
Jim Warner
3388f65c03 build-sys: correct all Makefile.am files for LOCALEDIR, etc
Some of the latest changes to Makefile.am files are missing.

This patch restores the LOCALEDIR variable, among others,
and dispenses with the include directives in the ps/ and top/
subdirectories since they're no longer needed.
2012-01-04 08:58:54 +11:00
Jim Warner
e64b6f70d7 top: update some programmer documentation (no logic, just comments)
This commit corrects some outdated programmer comments.

Additionally, certain nls justifications might become
increasingly obscure with the passage of time so some
previous nls commit text has been added as comments.
2012-01-04 08:58:54 +11:00
Craig Small
a99002e3fe Merge branch 'master' into nls
Conflicts:
	configure.ac
	pmap.c
	ps/Makefile.am
2011-12-26 09:11:27 +11:00
Jim Warner
e7f0906b58 top: update README with benchmarks using NLS support 2011-12-22 23:48:06 +11:00
Jim Warner
873df28b64 top: additions to search narrative in man documment 2011-12-22 23:48:06 +11:00
Jim Warner
f38c42ff21 top: final cleanup following nls conflict resolutions
This patch represents the final resting place for miscellaneous
changes not otherwise encountered or for which the resolution
was incomplete or incorrect.
2011-12-22 23:48:06 +11:00
Jim Warner
c465dca573 top: adapt 'locate/find next' search capability for nls 2011-12-22 23:48:06 +11:00
Jim Warner
2246663f66 top: changed 'err' to 'errmsg', avoid conflict with <err.h> 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
cb3b040718 top: repositioned nls.h to avoid redefine of procps.h restrict 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
edb71e5044 top: made prolog comments like those in procps:master 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
3d1f469995 top: restored static to scat(), not needed in top_nls.c 2011-12-22 23:48:05 +11:00
Jim Warner
fe7069dff0 top: corrected double #include missed at rebase 2011-12-22 23:48:05 +11:00
Jim Warner
434198e6e4 top: corrected missed escape seq from redesign 2011-12-22 23:48:05 +11:00
Jim Warner
26b4e0e1c6 top: optimization for show_special function 2011-12-22 23:48:04 +11:00
Jim Warner
da35f4a364 top: tweaked some xgettext emitted comments 2011-12-22 23:48:04 +11:00
Jim Warner
bc0f73e335 top: added #include of proc/readproc.h to top.h 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
090923e546 top: shortened some of the longer lines, mostly nls 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
18fc0b963d top: use existing unsigned vs. separate int 2011-12-22 23:48:04 +11:00
Jim Warner
eac96c37b5 top: corrected several programmer comments 2011-12-22 23:48:04 +11:00
Jim Warner
82c0dfd877 top: fix misapplied 'rh analysis #2: top' patch 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