A recent commit, that was intended to normalize cursor
handling, unintentionally exposed the cursor following
an Inspect 'Locate' request. This change will hide the
cursor once again through inst_view_choice's lifetime.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit f3a87cf634
Signed-off-by: Jim Warner <james.warner@comcast.net>
When top was changed to allow some core dumps, the two
potential end-of-job reports were disabled by mistake.
Later, that was corrected so that those reports always
were allowed, if the respective #defines were enabled.
However, if there was an early exit via a command line
option or an error, those reports should not be shown.
This commit may have gotten it right on our third try!
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 1da293bf59
commit d747659ad8
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit fixes allocation of the pid list so that it
is sufficient for storing the list terminator.
Additionally the vmflags printing in the -X mode is disabled
because it's too long. From now the vmflags are displayed
in the -XX mode only.
This commit changes the width measurement principle in the -X/-XX
modes so that a width of totals is measured instead of the width
of summands. The value of totals is always higher than the value
of summands. That additionally prevents the totals from having
a wrong indentation.
This commit also removes the minimum column width constraints
hardcoded to 7 characters.
This commit changes the processing principle of the -X/-XX modes
from 1-pass to 2-pass. A separate width measurement stage has been
added, so that the real maximum widths can be measured and used
for correct indentation.
The firstmapping variable now has a new value (2) used for the
width measurement stage (1st pass). The printing is disabled
in this stage. The file position is reset to the beginning
of the file once the end of file is reached and the printing stage
(2nd pass) begins.
It's questionable if this approach is sensitive to Read-after-Write
race conditions. Anyway, this feature is a good candidate for
a complete redesign in the future.
Additionally this commit introduces a final cleaning of the list
used for the evaluation of totals in the -X/-XX modes.
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>
Previously the pidlist variable was defined as unsigned long *
whilst the openproc function accepts pid_t *.
Both target types differ in size (8 != 4) and therefore the issue
mainly affects big endian architectures.
This commit changes the pidlist type to pid_t * so that it's
compatible with openproc.
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>
Some new kernel version added a line in /proc/pid/smaps listing a processes vmflags. This broke pmap such that pmap -X and pmap -XX would always fail.
This patch adds support for the vmflags field so that -X and -XX work again AND they display the flags.
Merge commit 'refs/merge-requests/8' of git://gitorious.org/procps/procps into merge-requests/8
This is largely Andrey's patch based upon merge request #7
If KLONG != 8 the summary didn't print for RRS and Dirty, this commit
restores this behavour for both sizes.
Ref: https://gitorious.org/procps/procps/merge_requests/7
Signed-off-by: Craig Small <csmall@enc.com.au>
The --group switch tells about parameter 'grplist' but detailed description
names it 'grouplist'.
This patch changes 'grouplist' to 'grplist'.
Signed-off-by: Andreas Bießmann <andreas@biessmann.de>
Signed-off-by: Craig Small <csmall@enc.com.au>
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>
freeproc was missing from the libproc API which meant while you could
allocate proc structures, you couldn't free them!
Bug-Debian: http://bugs.debian.org/681653
The “.I\-aux” syntax is broken (missing space): as a result, the hyphen
doesn't show up in the man page. Furthermore, according to man(1)
conventions, and in consistency with the rest of the manpage, it should
be bold instead of italic, the attached patch fixes this issue.
Signed-off-by: Craig Small <csmall@enc.com.au>
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>
The two extra extended pmap options were not tested previously.
We test against our known process and process 1 which we should
not be able to get data for.
Unfortunately, the tests cannot catch SEGSEGVs but they should.
Signed-off-by: Craig Small <csmall@enc.com.au>
While permissions suggests that /proc/#/smaps contents
are world-readable, in practice this file might not be
available to a non-root process. Whether this is a bug
in the kernel or an intentional design decision really
makes no difference. This commit will protect pmap -X.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit faec340719
Author: Dimitrios Apostolou <jimis@gmx.net>
Date: Thu Sep 27 22:08:04 2012 +1000
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>