Commit Graph

129 Commits

Author SHA1 Message Date
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
7a7e402563 top: follow ps lead, treat SIGUSR1/SIGUSR2 as harmless
Reference(s):
commit f62fd63d9e
http://www.freelists.org/post/procps/PATCH-procps-states-a-bug-is-hit-when-receiving-a-signal-871824

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:07:39 +11:00
Jim Warner
015e95dec3 top: remove undocumented alias ('V') for version ('v')
This is doubtless not quite the solution envisioned by
the submitter, but 'V' should probably never have been
used as an alias for 'v' now that we have forest-view.

(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/848290

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:07:38 +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
eeafd6cfe0 top: highlight all regular search string(s) when found
With the recent inspect search highlight provisions in
place, the lack of highlighting in task based searches
has grown from being only irritating to a real defect.

Thus, this commit introduces parallel functionality to
those searches initiated within a visible task window.
And just as separate inspect searches are possible for
each selection, per window task searches are provided.

However, it should be noted that there are differences
between task based searches and inspect type searches:

* There is no concept of out-of-view data when dealing
. with task rows -- if the data can't bee seen, it has
. not, in fact, been constructed from a proc_t struct.

* While inspect data is output at the character level,
. up to now all task display data was only potentially
. output and it was always based on a complete string.

* With task search highlighting, rows now containing a
. match must be output in pieces and, therefore, can't
. be optimized away like other rows which haven't been
. been altered. This is because top cannot predict the
. the contents of a search string or, how many matches
. might occur in a given row. Short search strings and
. many matches would raise buffer needs geometrically.

(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-11 22:54:25 +11:00
Jim Warner
2219c80514 top: refine inspect logic for already in-place matches
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-11 22:54:25 +11:00
Jim Warner
3b2b9a95e6 top: add inspect entry 'type' to alternate status line
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-11 22:54:25 +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
1623f1552d top: fix pid value displayed when kill default applies
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-11 22:54:24 +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
5ff464bdb1 top: highlight all inspect search string(s) when found
We have modeled the Inspect search provisions on those
provided by the 'less' pager. With this commit we take
the next step and provide for highlighting any strings
matched (and in view). Of course, top will continue to
adjust the beginning column so as to bring out-of-view
matches into view, while highlighting visible matches.

However, top won't emulate every 'less' behavior since
the following are seen as flaws in the user interface.

* when viewing true binary data, less makes no attempt
. to smooth the right margin by truncating unprintable
. symbols, thus creatng ragged unappealing right edges

* when viewing true binary data, less will always fail
. search requests regardless of surrounding characters

* less refuses to bring out-of-view found matches into
. view by adjusting the left-most column, if necessary

(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
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
a99f410d41 top: correct input anomaly if 'key repeat' is too fast
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-10 09:29:27 +11:00
Jim Warner
14170d0220 top: fix isolated inspect spelling error, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-10 09:29:27 +11:00
Jim Warner
3e7a70396c top: give inspect search algorithm a significant boost
The Inspect find algorithm has always been challenging
given the possibility that 'rows' might contain binary
data. Be that as it may, two small changes have proven
to dramatically improve the performance of such scans.

The first involves the case wherein if no match on the
'substring' portion of a row was found, then a pointer
representing the substring was increased by the length
of the search string, not the better/longer substring.
Thus, portions of the substring were always rescanned!

The second performance boost was achieved in this way:
pre-scanning each raw row for just the first character
in the search string now determines if a full match is
even possible. Therefore, repeated unproductive strstr
calls on individual substrings within that row will be
avoided. In a nutshell, 1 'if' with '}' did the trick!

(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-02 13:39:53 +11:00
Jim Warner
2db582e31e top: give inspect display page algorithm a small boost
This commit improves display performance when the user
has scrolled horizontally past the end of a top 'row'.

We can avoid the need to memset our buffer with spaces
and putp those spaces individually by exploiting logic
that already exists. If one '\n' character is inserted
into the buffer instead, the next terminfo string sent
will be Cap_clr_eol achieving exactly the same effect!

(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-02 13:39:52 +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
12c8d52057 top: add a flexible 'Inspect' capability, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:02 +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
9e99c84c48 top: kill/nice provide for a default pid, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:01 +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
4dfb01aa37 top: quiet lintian with escaped dashes in man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:00 +11:00
Jim Warner
44ceff845b top: include under nls support an overlooked error msg
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:00 +11:00
Jim Warner
99010db097 top: tweak scroll coordinates msg handling (again)
An earlier commit improved the scroll coordinates
message performance by offloading most of the work
to those occasions when column headers were rebuilt.

The only remaining per-frame costs were the addition
of some terminfo escapes and the Frame_maxtask count.

This commit further reduces those per-frame costs to
the absolute minimum.

Reference:
commit fbfaa868ba

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-26 18:58:42 +11:00
Jim Warner
0163abb48b top: allow exit from 2nd level help via <Esc> key
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-26 18:58:42 +11:00
Jim Warner
e77c8e8cf0 top: for performance, employ additional inlining
The 'refactor and enhance column width management'
recent redesign produced many subsequent benefits,
the latest of which is automatically sized fixed-width
non-scalable columns.

As expected, there was a cost associated with these
many enhancements.  That cost has now been identified
as a 1-4% performance degradation, depending on which
fields are being displayed.

This increased cost arises principally from current
drawing related function calls, whereas top-3.3.3 did
most of its drawing via macros effectively inlining
those duties.

This commit inlines the equivalent drawing functions,
thus eliminating the function call penalty, and places
this top on a par with top-3.3.3.  The trade off is a
modest additional 4k in executable size.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:13:14 +11:00
Jim Warner
f005411974 top: 'X' command offers auto option, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:13:14 +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
21237356ab top: map additional navigation keys, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Jim Warner
bff927711b top: map additional navigation keys
There were some gaps in the alternate navigation keys
top provided.  Additionally, some inconsistencies
existed in the supporting key table.

This commit adds the following new key equivalents,
mirroring the standard vim navigation keys:
. ctrl+alt+ k = pgup, ctrl+alt+ j = pgdown
. ctrl+alt+ h = home, ctrl+alt+ l = end

Also, the supporting table entries now consistently
follow these "directions":
. up/pgup, down/pgdown, left/home, right/end

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Jim Warner
edd8aae5ba top: avoid potential xterm state corruption
To support the cursor navigation keys, after saving
the termios structure top issues 'smkx/keypad_xmit'
during startup.  However, some terminals appear to
treat that directive as persistent which leaves a
corrupted tty state after top exit.

This commit reverses the above terminal directive
via 'rmkx/keypad_local' just prior to restoring the
saved termios structure at program end.

For discovering this bug, and providing the 'rmkx'
clue to its solution, thanks to:
  Kirill A. Shutemov <kirill@shutemov.name>

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Jim Warner
bb6cc9c159 top: for user justify feature, remember old-top needs
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Jim Warner
d58dc6b1e7 top: swat a bug introduced with recent width refactor
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
7557f3f754 top: with new 'X' command, WCHAN becomes fixed-width
This 'Sleeping in function' field was made variable
width because the length of current kernel symbols
usually exceeded the former top's 9 character limit.

As a variable width field it would steal valuable
horizontal display positions from other, more likely,
displayed fields such as COMMAND or CGROUPS.

With the advent of the new 'X' toggle, no fixed-width
non-scalable field need suffer permanent truncation.
Thus, WCHAN is being made fixed width with a default
size of 10 characters.

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

 top/top.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
2012-10-02 20:56:40 +10:00
Jim Warner
bbf8e44fb4 top: extend new 'X' command to include the TTY field
I have no idea what the maximum length of a terminal
name might be.  However, the library provides for up
to 128 characters (ouch).

So just to be safe, this commit extends the ability
to widen columns to embrace this field.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
47e1d063ac top: optional wider non-scalable cols, man document 2012-10-02 20:56:40 +10: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
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