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>
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>
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>
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>
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>
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>
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(-)
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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 02508b3d76http://www.freelists.org/post/procps/CStates-handling-new-switch,50
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>
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>
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>
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
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>