When two somewhat cryptic error messages were recently
changed to more user friendly text, the logic limiting
maximum columns was left unchanged at six. This always
was a rather arbitrary limit but now the revised error
message could actually be misleading (ok, a huge lie).
With a 1 line code change (macro actually), this patch
lifts the internal restriction on maximum columns. Now
the real limit is based on a window's physical x-axis.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 5a27c8095ehttp://www.freelists.org/post/procps/top-won-the-sigwinch-war,6
Signed-off-by: Jim Warner <james.warner@comcast.net>
A scrollback buffer used in several terminal emulators
could be a real inconvenience to a user following some
resize operations. Extra keystroke(s) would frequently
be required in order to properly render top's display.
After much sleuthing we unearthed two terminfo strings
which have the effect of disabling/restoring that darn
scrollback buffer. They were well hidden under a title
of strings 'to start/end programs using cup'. In turn,
'cup' deals with a tty's cursor addressing capability.
We don't care what you call them or what they refer to
so long as they get the job done. And these really do!
Be advised, however, that there are some side effects,
several of which can even be considered as beneficial:
. enter_ca_mode/smcup/ti disables scrollback buffering
( and that's good, it's what we had always hoped for )
. exit_ca_mode/rmcup/te restores the scrollback buffer
( but also restores screen contents existing pre-top )
( which is different from former program end results )
( where that last rendered screen was left untouched )
. the above screen replacement would impact ^Z suspend
( thus we keep the scrollback buffer disabled during )
( the suspend/resume sequence so that the users will )
( have a visual clue that top is suspended not ended )
If a terminal does not support these terminfo strings,
we will revert to top's former behavior at program end
where we position the cursor at screen bottom and then
output a single newline character. This will prevent a
shell prompt from embedding within top's final screen.
This commit's approach has been tested under a variety
of emulators and window managers, many of which linked
with libvte and others that employed their own scheme.
Examples are: gnome_terminal; kde konsole; lxterminal;
terminator; terminology; urxvt; xfce4-terminal; xterm.
I do now believe that the whole SIGWINCH deal is done!
(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-won-the-sigwinch-warhttp://www.freelists.org/post/procps/top-won-the-sigwinch-war,4
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit standardizes the usage of several terminfo
strings concerned with cursor position and visibility.
Henceforth we will adopt the following informal rules:
. Cap_home vs. Cap_clr_scr is preferred where possible
. Cap_curs_huge will be used with prompts for line i/p
. Cap_curs_huge will be used with help & color mapping
. Cap_curs_hide will be in effect in any other context
We've also added a missing Cap_clr_scr to the 2nd help
screen whenever the SIGWINCH interrupt was recognized.
This prevents a 'duplicated' row from appearing at the
top of the display (when resizing from small to large)
depending on an emulator's scrollback buffer contents.
(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>
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>
No top #define is enabled and that constitutes default
behavior. So whenever a default behavior should change
the define must be changed too if it is to remain off.
This commit simply changes top's default behavior with
respect to allowing/suppressing any potential flood of
SIGWINCH during resize operations, if running under X.
Formerly top would block those signals to reduce costs
of repeated refreshes. That yields a requirement where
the user would have to provide another keystroke for a
final display update. That keystroke may not always be
needed now, but it ultimately depends on some terminal
emulator's scrollback buffer. In any case, the cost of
re-sizing may go up a bit, under most window managers.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 4f33b6b8c5http://www.freelists.org/post/procps/top-won-the-sigwinch-warhttp://www.freelists.org/post/procps/top-won-the-sigwinch-war,4http://www.freelists.org/post/procps/top-won-the-sigwinch-war,5
Signed-off-by: Jim Warner <james.warner@comcast.net>
After carefully working our way to the point where the
excessive SIGWINCH interrupts are now throttled, along
comes a commit which reverses all those prior efforts.
Actually it doesn't. It simply allows one to choose if
all those efforts should be reversed or remain active.
Why in the world would you even want to consider that?
Quite simply, to opt for responsiveness over overhead.
Oh, and depending on the terminal emulator used for X,
by enabling this OFF_SIGWINCH #define you will be able
to avoid the need for an extra keystroke after resize.
Besides it was an interesting programming challenge to
see just how few lines of code would be needed to make
it possible. Bottom line? Only 1 source line required!
(actually 0 lines, since the define disables one line)
(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>
Whew, it was nip-and-tuck there for awhile but finally
we solved the SIGWINCH overload problem one finds with
most X window managers. Now if a window manager should
try to inundate ol' top with repeated SIGWINCH signals
they won't even be received so can't impact us at all.
And we achieve this miracle having never even issued a
sigprocmask, so all the top code executes with signals
totally unblocked. Intuition suggests it probably rubs
even more salt in the wound, but au contraire mon ami!
The key to our success was simply trading the 'select'
call for its cousin 'pselect'. Not only does that call
provide nanosecond granularity (vs. the former's usec)
but it takes a sigset_t parm which can then atomically
block the troublesome SIGWINCH guy until user input or
optional timeout. Net result? No more signal overload!
Now, if only we could just coax all terminal emulators
into one identical standard buffering scheme plus find
some way to emulate the most recent SIGWINCH, it would
be perfect. We would then obviate the user requirement
of typing yet 1 more key before seeing proper results.
(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-changehttp://www.freelists.org/post/procps/Sourceforge-project,7
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit primarily involves renaming functions plus
reorganizing logic in preparation for the next changes
which will hopefully yield the 'final solution' to the
excessive SIGWINCH signals under most window managers.
In this specific patch, the most significant change is
the introduction of a new 'ioa' function (io avail) to
focus all logic dealing with unsolicited user keyboard
input and exposed to signals and/or optional timeouts.
That new function is where our signal overload will be
ultimately defeated, if it is at all humanly possible.
(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>
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>
This commit just addresses the following minor issues:
. eliminate the leading tab character upon error exits
. standardized single key input as 'keyin', not 'chin'
. symbolic keys changed to guarantee no negative value
. placed most 'case' statement labels on a unique line
. standardized lvalue/rvalue convention in while loops
. fixed prototype declaration in the 'debug_END' macro
(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>
Some testing under a new distro revealed what appeared
to be a broken top Inspect request. When the selection
was made, the resulting output was scrambled/scrunched
at the bottom of the screen (as if ^J's were missing).
This anomaly surfaced under Fedora-18 which happens to
use the above ncurses version. The bug was not present
in version 5.9.20120714 (available with openSUSE 12.2)
or the more widely available version of: 5.9.20110404.
It has now been confirmed that this problem originated
in version 5.9.20120825. It was then that buffering of
output was changed from stdio to some internal ncurses
scheme so as to avoid problems with its SIGTSTP logic.
Thanks to a very prompt response from Thomas E. Dickey
we also learned that contrary to the documentation the
putp logic does not call putchar internally. Thus, the
single putchar that Inspect was employing was actually
mixing 2 different buffering schemes: ncurses & stdio.
Thus, from now on we'll use putp() exclusively and try
to achieve single char output as efficiently as we can
while meeting that putp() string argument requirement.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
https://bugzilla.redhat.com/892674
Signed-off-by: Jim Warner <james.warner@comcast.net>
There existed a small chance that the display could be
corrupted when a search string was found within a row.
For that to happen, conditions like these were needed:
. a very short Locate string was active in some window
. the string matched part of a terminfo <esc> sequence
. that sequence was used in highlighting running tasks
. the 'x' toggle was active (sort column highlighting)
One solution to this potential problem was to manually
turn off sort column highlighting before using Locate.
But rather than rely on a user remedy, we'll automate.
Since other top provisions were already being enforced
when Locate was in use (off 'i' and/or 'u'/'U'), we'll
now also force column highlighting off when the search
string in a given window is not empty. However, unlike
idle tasks and user filtering, when that search string
*is* emptied, we restore highlighting for that window.
(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>
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>
This potential problem is caused by frequently spawned
and short lived tasks which happen to sort above a row
containing a match from an active Locate request. It's
most likely to be visible when under Forest View mode.
This commit will eliminate a potential duplicated row.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Both of the 'file' and 'pipe' Inspect read buffers are
always 2048 bytes bigger than is actually needed which
provided for some slightly simplified row paint logic.
However, with no real rcfile inspect entries, and thus
operating in 'demo' mode, the allocated buffer is only
2048 bytes total. This can produce a valgrind warning.
This commit simply puts the inspect 'demo' buffer on a
par with other allocated real buffers (an extra 2048).
(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>
In a effort to anticipate a potential future wishlist,
the recent '-o' sort override command line switch will
now support an override of the sort direction as well.
By prepending a '+' or '-' to any valid field name the
user will be able to guarantee a specific desired sort
direction. The '+' forces a high-to-low (normal) order
while a '-' reverses that to yield a low-to-high sort.
Without this addition users would be left to the mercy
of whatever was last specified for Curwin as reflected
in the rcfile or top's default of a high-to-low order.
(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>
The recent change to task area memory scaling was just
a little short of optimum in its consistency and upper
limits. In fact, top could only scale memory fields up
to a maximum of 99.9999 TiB (with VIRT a little more).
While that seems like more than enough it was actually
artificially low, due to an unnecessary decimal place.
So, this commit standardizes both precision and widths
to achieve a minimum amount of scaling beyond the user
requested target plus reclaim some horizontal spacing.
. VIRT & DATA are now 7 bytes wide (not eight and six)
. other memory fields are 6 wide (were formerly seven)
. as before, KiB shows whole numbers only (no decimal)
. MiB, for its precision, shows a single decimal place
. all other memory ranges display three decimal places
The net result is a more homogeneous display with less
forced scaling and the recovery of three lost columns.
(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-enhancements-i-hope,1
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit will allow user filtering as long as there
is a valid number representing a potential user ID. It
will serve, for example, chroot environments where the
specific user may be unknown to a host, or vice versa.
(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-enhancements-i-hope,1
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit was adapted from the openSUSE patch, whose
original comments appear between the --- marker below.
It should be noted, however, that the original changes
were ineffective (wasted) because 'Batch' mode had not
yet been set when signals were being checked and their
handlers established. Thus, SIGHUP was never bypassed.
(of course, only our comments are perfectly justified)
------------------------------------------------------
Do not setup SIGHUP signal handler if we are in the batch mode
Top enables a signal handler for the SIGHUP signal (loss of terminal). While
this makes sense for top's default interactive mode, it doesn't make any sense
for batch mode. If you run top in nohup just to collect data over time and
disconnect top finishes which is not what one would expect.
------------------------------------------------------
Reference(s):
http://www.freelists.org/post/procps/top-enhancements-i-hope,1
Signed-off-by: Jim Warner <james.warner@comcast.net>
Everyone has either accepted this potential distortion
or patched top to eliminate it. Now, the time has come
to regain some consistency when calculating that %CPU.
We'll now limit such values to: 100.0 * total threads.
And, it took way too long to address this little flaw.
(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-reportshttp://www.freelists.org/post/procps/top-regression-reports,1
Signed-off-by: Jim Warner <james.warner@comcast.net>
The delay interval is kept in the rcfile in a floating
point format and is thus susceptible to changes in the
locale between invocations. So values written as #,###
could not be read if a new locale uses decimal points.
This commit takes control of our own decimal point and
will henceforth make top immune to locale switcharoos.
(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-has-a-localedpendent-config-file-toprchttp://lists.opensuse.org/opensuse-bugs/2012-12/msg01466.html
Signed-off-by: Jim Warner <james.warner@comcast.net>
With the increased width and precision of memory and %
columns, the proliferation of 0's when there's nothing
to report seems like a distraction versus useful data.
This commit introduces the '0' toggle which can either
display or suppress those zeros. And, like the scaling
states this new state is also preserved in the rcfile.
(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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>