. prevent any input recall overrun if window downsized
. adjust translation notes for true column hdr maximum
Signed-off-by: Jim Warner <james.warner@comcast.net>
In release 3.3.6, some commands were equipped with the
concept of a 'default pid'. The initial implementation
meant that the intuitive <Esc> key would not always be
treated as one would expect under any well behaved UI.
This patch ensures the expected <Esc> key behavior of:
terminating user input while still making possible the
necessary distinction between 'no input' & 'defaults'.
Reference(s):
http://www.freelists.org/post/procps/top-Escape-doesnt-abort-kill-command
Signed-off-by: Jim Warner <james.warner@comcast.net>
The granularity of /proc/uptime is fixed at hundredths
of a second. And, since we can cycle faster than that,
we are exposed to 'nan' when calculating elapsed time.
This commit will protect us from that outcome when the
delay interval has been set to an extremely low value.
Signed-off-by: Jim Warner <james.warner@comcast.net>
In addition to eliminating numerous single quote usage
this commit also escaped '\' a few overlooked hyphens.
And some 'unformatted' spacings were adjusted as well.
Signed-off-by: Jim Warner <james.warner@comcast.net>
The majority of changes in this commit are intended to
enable translation of top's man page. There were three
kinds of errors as seen by that po4a-updatepo program.
. a valid but unrecognized request concerning no-break
. an internally defined macro with a groff .de request
. occasional apostrophe at the beginning of some lines
With respect to the apostrophe, some have been changed
to back-tic since line placement could not be assured.
And other parts were re-flowed to avoid temptations to
escape as \' (technically an acute accent). Of course,
the opening back-tic with closing apostrophe looks odd
when ASCII, but should be rendered correctly as UTF-8.
It may yet be necessary to change the remaining single
'opening' quotes to back-tics as translation proceeds.
Should that become necessary, I intend to reduce quote
usage to the bare minimum throughout the man document.
There were also some formatting changes to enhance the
man2html output and then to other formats via htmldoc.
And, I wish to acknowledge that my meager groff skills
do not serve those programs very well at all. In other
words groff yet remains mostly incomprehensible to me.
Lastly a few content plus copyright updates were made.
Message(s):
. Unknown macro '.c2 `'. Remove it from the document, or refer to the Locale::Po4a::Man manpage to see how po4a can handle new macros.
. This page defines a new macro with '.de'. Since po4a is not a real groff parser, this is not supported.
. Unknown macro ''real time' scheduling priority.'. Remove it from the document, or refer to the Locale::Po4a::Man manpage to see how po4a can handle new macros.
Reference(s):
. oriiginal post/patch
http://www.freelists.org/post/procps/Translations-for-man-pages
Signed-off-by: Jim Warner <james.warner@comcast.net>
If a system's time is adjusted backwards, then elapsed
time could appear as negative. This yielded a negative
%CPU value. Alternately if zeros were suppressed ('0')
the result was a blank %CPU column. In both cases that
distortion would last for one display cycle or until a
user forced a display refresh via some keyboard input.
The original recommendation was trading gettimeofday()
for clock_gettime() using CLOCK_MONOTONIC. But on some
systems that might not be possible, forcing the use of
CLOCK_REALTIME instead. Not only would that complicate
the build system, but it may leave us with minus %CPU.
Another approach was to ensure that elapsed time could
never be negative. Of course, this produced distortion
of %CPU values but it would be proportionally correct.
This wasn't dissimilar to a distortion already present
should the time be adjusted forward or backward within
any 'remaining' top delay intervals. These aberrations
would be avoided with clock_gettime & CLOCK_MONOTONIC,
but that is a less than ideal solution as noted above.
This final solution, which originated down under, will
simply rely on the /proc/uptime seconds, which will be
immune to *any* tampering with the system clock. Thus,
we now have a fix for the distortion we didn't know we
suffered plus a negative %CPU that began this odyssey.
Thanks to:
sk.alvin.x@gmail.com, for the original effort
jcapik@redhat.com, for a heads up on CLOCK_MONOTONIC
csmall-procps@enc.com.au, for the best suggestion of all
Reference(s):
. original post/patch
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday
. heads up on CLOCK_MONOTONIC
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday,2
. the final solution
http://www.freelists.org/post/procps/PATCH-top-use-clock-gettime-instead-of-gettimeofday,11
Signed-off-by: Jim Warner <james.warner@comcast.net>
Minor fixes that the translator (Yuri) has found in some of the
strings. You only know how many typos and thinkos you have when
someone is trying to translate it.
Signed-off-by: Craig Small <csmall@enc.com.au>
Since its inception top has always used enumerators to
identify displayable fields. They've taken the form of
P_PID, etc. As it turns out, something has changed for
libc6-dev versions beyond 2.17-93 wherein 'P_PID' will
now be exposed via stdlib.h. I have not pinpointed the
exact cause but it may depend on header include order.
This patch just trades top's long standing 'P_' prefix
convention for that of 'EU_' (short for enumerator). I
cannot find *any* header under /usr/include/ currently
utilizing this particular three character combination.
And as a further safeguard top will henceforth include
'system' specific headers after the standard includes.
Reference(s):
http://www.freelists.org/post/procps/top-wont-compile-anymore
Signed-off-by: Jim Warner <james.warner@comcast.net>
When top originally responded to the potential libnuma
stderr write, the library was consistently called with
each refresh cycle. That, in turn, guaranteed that any
warning message would be seen at program end by virtue
of: 1) having been issued before the 2nd refresh cycle
and; 2) benefiting from inherited /dev/null buffering.
A later efficiency refactor meant the numa library may
not always be called with every refresh cycle. Rather,
it was only called if top was in one of two numa views
(the '2' or '3' toggles). That, in turn, resulted in a
loss of any warning message at program end unless numa
mode had been preserved in the rcfile. In other words,
if top was started normally then a single cycle stderr
redirect would have long passed by the time the '2' or
'3' toggle was activated. The warning message actually
was spewed but quickly lost to the full screen refresh
which follows all keyboard interactions with the user.
This commit simply moves the restoration of our stderr
redirect to program end (instead of that first display
refresh). Now, any libnuma stderr warning message will
appear as the concluding output line upon quitting top
without regard to when any numa mode view was invoked.
And since this technique might be useful in some other
context (as an example of how to 'buffer' stderr) it's
been generalized with its own #define. But to maximize
its usefulness, the original redirect should be issued
much earlier in pgm startup than top has chosen to do.
Reference(s):
. original libnuma stderr response (msg seen)
commit 35dc6dcc49
. numa refractoring for efficiency (msg lost)
commit f12c0d5c6e
Signed-off-by: Jim Warner <james.warner@comcast.net>
Apparently there are occasions when NUMA nodes may not
always be contiguous. Under such conditions nodes that
were not used would still occupy precious Summary Area
space showing 100% idle, under the '2' command toggle.
With this commit top will no longer display numa nodes
that have no associated cpu when the '2' toggle is on.
But just in case we wish to return to former behavior,
a new #define called OFF_NUMASKIP has been introduced.
And as an aside, a recent refactor mentioned below set
the stage for this patch to be 'self-tuning'. In other
words, if an inactive/non-displayed node should become
active (if even possible), then top will begin showing
such a node automatically with the next screen update.
Unfortunately, all inactive nodes now 'suppressed' are
still accessible via the '3' command. Those nodes will
just be displayed as empty (no associated cpus shown).
This is not really a top problem but more of a libnuma
and/or user deficiency. The library lacks the means to
validate a node id and the user then input a node that
was not even shown under a '2' toggle Summary display.
( too bad libnuma does not offer an 'is_node_active' )
( type function so top could warn a user when such a )
( discontinuous node was requested using his '3' cmd )
( sure, top could achieve this objective himself but )
( that would require making yet another array global )
( which i'm just not in the mood to do - besides, we )
( have already made enough concessions to libnuma.so )
Lastly, an existing #define (PRETEND_NUMA) was changed
to 'disable' node #1 so as to simulate a discontinuous
node. This allows testing of the '2' and '3' commands.
Reference(s):
http://www.spinics.net/lists/util-linux-ng/msg08671.html
. set stage for self tuning
commit f12c0d5c6e
Signed-off-by: Jim Warner <james.warner@comcast.net>
A recent change involving a one cycle stderr redirect,
to handle a libnuma potential transgression, failed to
follow normal global variable naming conventions. This
patch will capitalize the 1st letter of 'Stderr_save'.
Reference(s):
commit 35dc6dcc49
Signed-off-by: Jim Warner <james.warner@comcast.net>
Excluding those special X_XON/X_XOF enums, which might
not even be present, restore strict collating order of
all the case labels in the task_show switch statement.
Also, adjust a few sort callbacks for the same reason.
Signed-off-by: Jim Warner <james.warner@comcast.net>
The recent addition of namespaces, combined with those
potential suse out-of-memory fields, means that we are
close to the maximum number of fields poor ol' top can
display. Imagine, the really old top was limited to 26
fields (28 with the suse hack) and this top had neared
the version 'g' rcfile limits which were a healthy 55.
This patch adds another 15 fields to the maximum while
making it even easier to increase in the future. Also,
top still silently accommodates older config files all
the way back to the original pre-ng version top-3.2.8!
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch is inspired by the 'minimize numa overhead'
patch. It trades the use of subscripts for pointers to
avoid gcc repeated subscript offset calculation bloat.
Now, throughout the cpus_refresh function, a subscript
will be resolved just once & this will (dramatically?)
reduce the path-length taken for each and every frame!
For example, a non-optimized compilation could produce
400+ fewer machine instructions through pointer usage.
[ ok, optimized compiles only save 18+ instructions! ]
Lastly, any residual 'symmetry only' crap is now gone!
Signed-off-by: Jim Warner <james.warner@comcast.net>
A recent libnuma potential corruption problem solution
has caused me to reevaluate some associated numa logic
for efficiency. Here is a summary of the problems that
exist with current libnuma/user possible interactions:
. Whenever the numa library was present extra overhead
would always be incurred in maintaining the node stats
even when the '2' or '3' commands were not being used.
. As part of such overhead a separate loop was used to
reinitialize each cpu/node structure with each display
cycle so that prior accumulated totals were preserved.
Again, it didn't matter if numa data was really shown.
This commit attempts to refocus on the 'critical path'
costs in a running top by optimizing for the occasions
when numa node data is not being displayed. Under such
conditions, no extra overhead will be incurred whether
or not a distribution has the libnuma library present.
To achieve this goal, some additional overhead will be
incurred, but only when actually displaying numa data.
And all such new costs have been minimized in spite of
the gcc inclination to duplicate subscript resolution.
Reference(s):
commit 24bd950cb2e1722d459461f0f9c0c30a4b9ffdaa
Signed-off-by: Jim Warner <james.warner@comcast.net>
A recent libnuma potential corruption problem solution
suggests that libnuma could change in the future so as
to not spew to stderr. This then raises a question how
top could exploit any such library change since we are
currently locked into version #1 of the library by way
of our dlopen("libnuma.so.1", RTLD_LAZY) runtime call.
While not an ultimate solution, this commit will first
try for the most recent version of that library during
top's startup before trying the original libnuma.so.1.
We do this via the unqualified library soname symlink.
For this new dlopen() call to succeed, technically the
numa 'devel' package would usually have been required,
but that's not always true with every distro. And when
the libnuma.so symlink isn't present, it can always be
manually added should a newer & better behaved library
arrive & users tire of the stderr warning at top exit.
Reference(s):
commit 24bd950cb2e1722d459461f0f9c0c30a4b9ffdaa
Signed-off-by: Jim Warner <james.warner@comcast.net>
Confession is supposed to be good for the sole, right?
After a senior moment regarding the 'x' toggle quirks,
and thinking top had somehow regressed, I concluded an
additional explanatory note might well be appropriate.
Those quirks were already documented under the 5d & 5e
topics. But there was no such caution documented under
the 'x' command explanation itself, found in topic 4c.
Signed-off-by: Jim Warner <james.warner@comcast.net>
There is a chance that the libnuma library may corrupt
top's display with some stderr warning messages in the
event something under /sys/devices/system/node/ cannot
be accessed. And, while 2 overridable 'weak' functions
are provided to alter such behavior, we can't use them
since top dynamically links to the library via dlopen.
This commit will redirect stderr to '/dev/null' during
just the first screen display cycle. Thus we can avoid
the corruption which would have remained visible until
the underlining screen row's data had finally changed.
Lastly, this patch should allow such a library warning
to actually appear when one finally exits our program.
[ i think the libnuma folks should consider changing ]
[ the error/warning interfaces to accommodate dlopen ]
[ rather than forcing something like the ugly kludge ]
[ we have employed or libnuma dependency on everyone ]
Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=998678
Signed-off-by: Jim Warner <james.warner@comcast.net>
When Other filtering was introduced the nature of what
constituted a displayed row changed. No longer would a
task_show() call guarantee that another line is shown.
Rather, a non-empty string must have also been tested.
Unfortunately, when any task window was being filtered
for 'idle' mode or a particular 'user', the proc index
was incremented twice due to the perils of copy/paste.
Combining such an index increment with the new test of
task_show results works fine if filtering is inactive.
This was a particularly insidious bug which meant that
an adjacent task would be skipped whenever the current
task met 'idle' and/or 'user' filter criteria, and was
not otherwise excluded due to 'Other' filter criteria.
And, since it was the very next task that was ignored,
the bug was very susceptible to a window's sort order.
This could be illustrated when filtering on some user,
while sorting on PID. Then, toggling Forest View could
make otherwise unseen tasks appear and then disappear.
User workarounds are possible via interactive commands
trading the 'i' and 'u'/'U' provisions for the 'o'/'O'
other filtering capability thus avoiding an extra i++.
But that is certainly less than ideal and doesn't help
the 3.3.7 and 3.3.8 distorted command line provisions.
( this little buggie may end up costing me my pocket )
( protector, my coding badge & maybe even my cubicle )
Reference(s):
http://www.freelists.org/post/procps/Idle-elides-nonidle-processes
. bug originated with 'Other' filtering
commit 5edc6fb317
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch adds the final newline when exiting 'Batch'
mode. Interestingly, it has been missing since release
3.3.5 but undetected until the Redhat bugzilla report.
Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=1008674
Signed-off-by: Jim Warner <james.warner@comcast.net>
Normally, the internally tracked 'Screen_cols' can not
exceed the lessor of 512 or actual screen width. There
was one case, however, where that 512 byte upper limit
was no longer properly imposed as it should have been.
When operating in 'Batch' mode the actual screen width
was allowed to be exceeded when the optional -w switch
was also used. But, it should never have exceeded 512.
This patch ensures the upper limit is always observed.
Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721204
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch addresses the four '-Wunused-result' errors
generated whenever an optimized compile is invoked. It
also made the configs_read() guy a little more robust.
In the process, some logic was rearranged slightly and
some comments were re-indented simply for consistency.
Reference(s):
warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]
warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]
Signed-off-by: Jim Warner <james.warner@comcast.net>
When the final solution for cursor positioning for all
^Z or ^C cases was introduced the revised placement of
message line management introduced with the window mgr
'screen' refactor was retained. Those two commits mean
that a former tgoto was no longer needed when clearing
that msg line or displaying the scroll coordinate msg.
This patch eliminates the tgoto employed by frame_make
while assimilating a now defunct show_scroll function.
Reference(s):
. final cursor positioning for ^Z or ^C
commit 46a1356219
. 'screen' window manager refactor
commit 0fe393ff27
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch just provides a visual clue to separate the
values reported for cached Memory from other values on
the Swapped line (which is being shared due to space).
Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718670
Signed-off-by: Jim Warner <james.warner@comcast.net>
Some more (very obscure) conditions where a suspension
or program end might embed the shell prompt within top
output have been uncovered beyond the 2 already known.
We had already covered some suspend/end contingencies:
1. the users were using the 'fields management' screen
2. the users were prompted for any line oriented input
However, there remained some situations where ^Z or ^C
could still produce a misplaced cursor + shell prompt:
3. the 'g' command while waiting for the window choice
4. the 'W' command if about to overwrite an old rcfile
5. the '=' command when exploiting the Inspect feature
6. the period during which any error message was shown
But, even when all those bases are covered there still
remains a remote possibility that such interrupts will
occur during a top repaint cycle. So rather than throw
yet more code at these self-inflicted problems perhaps
it is better if we just throw in the proverbial towel.
Thus, I'll take the only sane approach and restore the
results expected ever since top's inception and before
scrollback buffers entered the picture. Namely, with a
^Z or ^C the cursor will be placed on the final screen
row. That usually means it will immediately follow the
last output line but it may follow many blank lines if
the user interrupts top when *not* on the main screen.
Reference(s):
. expanded repositioning (for line oriented input)
commit 33104a2bcc
. introduced repositioning (for fields management)
commit 5c974ff44d
. scrollback buffers (the cursor handling changes)
commit dedaf6e1a8
Signed-off-by: Jim Warner <james.warner@comcast.net>
An obscure bug has been discovered where a 'W' with an
old rcfile, warning against overwrite, would display a
cursor that should normally be hidden. This followed a
user's reply. So some logic was rearranged just a bit.
Signed-off-by: Jim Warner <james.warner@comcast.net>
A recent patch introduced the ability to recognize the
need to reposition the cursor at suspension or program
end. There remained unmet 1 additional potential need.
This commit extends that ability to embrace line input
so that if a user issues ^Z or ^C while being prompted
the resulting shell output will no longer be embedded.
Reference(s):
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,7
commit 5c974ff44d
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit mostly justs renames a few identifiers but
it also will now suppress any end-of-job report if top
wasn't ended via the 'q' key convention (i.e. signal).
Signed-off-by: Jim Warner <james.warner@comcast.net>
The title of this commit is actually quite misleading.
Were it more accurate, it would at least mention a tty
emulator's scrollback buffer, which was the cumulation
of a long pursuit to reduce the SIGWINCH overhead when
a window manager carelessly floods an application with
that signal *while* a user is still resizing a window!
Disabling and enabling that scrollback buffer resulted
in the final top display replaced with original screen
contents, a phenomenon acknowledged at the time but it
also represented a user interface change which has now
produced the first request for return to old behavior.
After the SIGWINCH dust settled, another problem arose
regarding behaviors under the 'screen' window manager.
In response, top was refactored a bit to avoid display
corruption. That was before discovering 'screen' could
duplicate the scrollback buffer behavior top expected.
As it turns out, the 'screen' refactoring had probably
made scrollback buffer manipulation unnecessary. Still
one could argue that a window should not be allowed to
scroll while a constantly updating program was active.
The solution represented in this commit returns former
behavior at program end (retaining top's last screen).
And if we ever wish to disable scrollback buffers, the
associated logic was retained but made conditional. It
is not reflected in configure.ac but might be someday.
Lastly, this commit corrects cursor positioning when a
^C is issued under 'Fields Management' at any terminal
that didn't have a scrollback buffer (i.e. a console).
Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=977561http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,1
. screen program refactor
commit 0fe393ff27
. scrollback buffer disabled
commit dedaf6e1a8
. sigwinch management defines
commit adca737758
commit 4f33b6b8c5
Signed-off-by: Jim Warner <james.warner@comcast.net>
The .Bd and .Ed macros, from the mdoc collection, have
caused a few raised eyebrows (lintian, doclifter, etc)
in the past. With this commit, we will trade their use
for the standard existing groff .nf & .fi equivalents.
Signed-off-by: Jim Warner <james.warner@comcast.net>
When the plug-in approach to NUMA support was added, I
carelessly employed the compile-time linker convention
for naming the library. Technically this then required
the 'devel' package for NUMA support to be present for
the unqualified soname symlink to be available. Either
that or one must have manually created such a symlink.
This commit adds the missing major version to dlopen()
of libnuma.so.1 so simply having a more likely package
such as 'numactl' will enable both '2' & '3' commands.
References(s):
http://www.freelists.org/post/procps/top-NUMA-node-CPU-utilization-support,25
. initial dlopen support
commit edba932a7e
Signed-off-by: Jim Warner <james.warner@comcast.net>
If top were invoked under the 'screen' window manager,
writing the terminfo string 'exit_ca_mode' at top exit
would not restore the display to the state existing at
the time top was started. That's what occurs normally.
The net result of that failure was a corrupted screen.
However, there is a 'screen' configuration option that
will produce proper 'rmcup' behavior, but it is off by
default. That screencr option is known as 'altscreen'.
I stumbled across this provision by cloning the screen
git repository then searching for references to 'cup'.
If 'altscreen on' had been in either the /etc/screenrc
or the $HOME/.screenrc configuration file, my poor old
top would never have been accused of such corruptions.
Of course, the Programming Gods decree that any simple
solution for our problem must always be revealed last.
So before discovering that rc option, another approach
was taken involving top only. With just a little extra
refactoring of top display logic he was made immune to
any such quirk in the implementation of 'smcup/rmcup'.
I always feel good about any enhancement that actually
reduces the total number of lines of code. Even though
this change involved mostly rearranging some logic, it
yielded one less line (can't judge by diffstat because
of braces & notes). Anyway, rather than requiring some
change to a screenrc file, now we are self-sufficient.
Reference(s):
procps ---------------------------------------------
https://bugzilla.redhat.com/show_bug.cgi?id=962022http://www.freelists.org/post/procps/top-procpsng337-no-screen-cleaning-at-exit,3
. top : disable tty scrollback buffer to improve SIGWINCH
commit dedaf6e1a8
screen ---------------------------------------------
git://git.sv.gnu.org/screen.git
. Improve cursor store/restore on smcup/rmcup.
commit f95352946080be803b794c9f2733d8c809c1a39a
. Fix using alternate screen buffers in some cases.
commit ad56f746c6243d45124485d198d577bdbb78071c
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558724
Signed-off-by: Jim Warner <james.warner@comcast.net>
When summary & task area memory scaling was introduced
in release 3.3.6, the memory field widths were widened
slightly so unscaled KiB values could be provided more
consistently and scaled values (beyond MiB) could show
3 decimal places of precision. However, some users may
prefer the former widths/precisions for memory fields.
This commit will provide a build time configure option
to return top to those former defaults as a compliment
to a new %CPU & %MEM field precision configure option.
Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=707648
commit 21e550bc08
Signed-off-by: Jim Warner <james.warner@comcast.net>
When summary & task area memory scaling was introduced
in release 3.3.6, the percentage columns were expanded
to provide 3 decimal places of precision. In hindsight
that may have been overkill, making those columns more
of a distraction than useful, with just too much info.
This patch will revert those columns to the former one
decimal place. And as was true, that decimal point may
be sacrificed depending on the number of cpus present.
And, in case anyone might prefer additional precision,
a build option can provide it (--enable-wide-percent).
Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=707648http://www.freelists.org/post/procps/What-happened-to-my-top,1
commit 21e550bc08
Signed-off-by: Jim Warner <james.warner@comcast.net>
Some versions of man have had trouble with the leading
apostrophe employed with interactive commands/toggles.
Instead, a '?' would be displayed in their place. With
this patch all such conventions have now been removed.
Signed-off-by: Jim Warner <james.warner@comcast.net>
The earlier commit purporting to allow top to be built
in the absence of that dynamic linking library stopped
just a little short of the truth. So this will fix it.
Reference(s):
commit 5686877cd4
Signed-off-by: Jim Warner <james.warner@comcast.net>
The NUMA/Nodes support in top has gone through several
evolutions (primarily dealing with build-sys options).
With this commit the library dependency issues are now
moot and the responsibilities for run-time loading and
dynamic linking are assumed by the top program itself.
Henceforth, if top is executed in an environment where
libnuma.so is present, top will offer such extensions.
Even more importantly, when a missing libnuma is later
installed, top will offer numa support auto-magically.
All NUMA/Node build-sys dependencies are thus removed.
The former NUMA_ENABLED define has become NUMA_DISABLE
should anyone wish to test user interface implications
in an environment that *does* have libnuma. It is also
represented as the ./configure option: --disable-numa.
Lastly, the 't' (View_STATES) toggle will be forced on
for sanity whenever the '1', '2' or '3' keys are used.
Reference(s):
. original idea from: Dr. Fink <werner@suse.de>
http://www.freelists.org/post/procps/top-NUMA-node-CPU-utilization-support,18
. original numa suppoort
commit 8d989c68c0
Signed-off-by: Jim Warner <james.warner@comcast.net>
Oh that poor ol' build system. With this patch it will
have gone through three separate incarnations in terms
of NUMA/Node support. Those 3 iterations consisted of:
1. A 'porridge too hot' where the top numa support was
enabled if it was built in the presence of libnuma and
the numa.h header. But if the numa library wasn't part
of core packages, that would have broken poor old top.
2. A 'porridge too cold' where numa support was off by
default and must have been explicitly enabled when the
./configure script was run. This could have meant that
distros might not distribute a numa-aware procps, even
though their numa library would have been distributed.
3. And this 'porridge' where the top numa support will
become a 'plug-in' feature activated when the presence
of libnuma.so can be verified at runtime. We'll do our
own loading and symbol resolution (with some help from
dlopen in libdl). Thus maintainers' responsibility for
enabling numa support and then satisfying that library
dependency is now an entirely optional --disable-numa.
As Goldilocks might say about our current configure.ac
"Ummm, I think this porridge tastes just about right".
Reference(s):
. 1) too-hot
commit 87ac6383bb
. 2) too-cold
commit 53fd7dd1ed
. original idea from: Dr. Fink <werner@suse.de>
http://www.freelists.org/post/procps/top-NUMA-node-CPU-utilization-support,18
Signed-off-by: Jim Warner <james.warner@comcast.net>
Almost forever, top has been accessing the /proc/stat/
directory one line at a time until either smp_num_cpus
was reached or (more recently) Screen_rows is reached.
When NUMA/Nodes support is enabled screen rows will no
longer serve as a limit because all cpus must be read.
With this commit, the entire /proc/stat/ directory can
be read at once so all statistics will be frozen. Thus
individual cpus will no longer keep "ticing" until top
gets around to accessing them via some separate fgets.
The distortion this commit eliminates was quite easily
seen when comparing old/new tops using: individual cpu
stats vs. cpu summary; a healthy delay interval of 3-5
seconds; manually synchronized update cycles (the hard
part); some system loading (maybe another top at -d0).
Additionally, this patch eliminates some long standing
unnecessary initialization made possible because of an
allocation via calloc. If some parts are never touched
by sscanf due to a kernel version, it's unnecessary to
repeatedly re-initialize those portions to zero again.
Reference(s):
. numa extensions added
commit 8d989c68c0
. useless initialization evolution (old to new)
commit e54c8239b1
commit 9278134e49
commit fd62123562
commit f348575edc
Signed-off-by: Jim Warner <james.warner@comcast.net>
With the addition of NUMA/Node support and the ability
to emulate such support even in the absence of libnuma
and numa.h, the maximum number of cpus top can emulate
was increased to make numa emulation more interesting.
( whew, that's an awful lot of "emulates", me thinks )
Reference(s):
commit 8d989c68c0
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit extends the top Summary Area cpu states to
include information on Non-Uniform Memory Architecture
nodes. It is based upon changes originally proposed by
Lance Shelton who was instrumental in the final patch.
With this change, the user will have new commands that
will provide alternatives to the individual cpu stats:
. '2' toggles between cpu & numa node summary displays
. '3' provides node summary and related cpu statistics
These extensions required some minimal system support.
Typically, the numactl package (and maybe libnuma-dev)
are all that's needed to show a single node which owns
all the processors. Failing that, or for slightly more
variety, top also offers a #define named PRETEND_NUMA.
(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>
Signed-off-by: Lance Shelton <LShelton@fusionio.com>
This commit provides the NEWS and man document changes
supporting the new NUMA/Node top program enhancements.
For providing the initial impetus for this enhancement
I wish to thank Lance Shelton <LShelton@fusionio.com>.
(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>
Signed-off-by: Lance Shelton <LShelton@fusionio.com>
This patch provides the build system support for those
top extensions dealing with the NUMA summary displays.
For providing the initial impetus for this enhancement
I wish to thank Lance Shelton <LShelton@fusionio.com>.
(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>
Signed-off-by: Lance Shelton <LShelton@fusionio.com>
When 'Other Filtering' was introduced the idea of what
constituted a displayed row changed. No longer was any
call to task_show assured of consuming one screen row.
Now the determining factor was whether or not the rows
were empty. This worked Ok until a certain Find string
was active then the entire display could be corrupted.
With Find active, the task_show() function alters each
returned row while highlighting each visible match. If
the search was on a single byte value & matched at the
beginning of a row the match got overwritten with '\0'
which then appears empty upon return to window_show().
So that row would not be counted as having been shown.
This was best illustrated with a Find on a single ' '.
This patch will restore proper 'Find/Locate' behavior.
Reference(s):
commit 5edc6fb317
Signed-off-by: Jim Warner <james.warner@comcast.net>
If the 'Inspect' feature was used to view a file which
contained binary (unprintable) data, and when the last
line for such a file was purely unprintable, then that
line length would be overstated by the terminal width.
This was also the occasion where valgrind might object
over potential reference to some unitialized value(s).
It was a harmless situation and somewhat rare to begin
with. Anyway this commit will eliminate the potential.
Additionally, supporting readfile logic was simplified
and the 'status line' bytes read is now more accurate.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Some recent nls work on that pmap program necessitated
a return to nls translation file creation for testing.
As it turns out, my skills used in pseudo-translations
had become rusty and some newer LC_MESSAGE directories
may have been introduced since last needing the topic.
This patch just updates some programmer notes to agree
with this most recent effort and for future reference!
Reference(s):
. pmap nls support
commit 0c0c543466
Signed-off-by: Jim Warner <james.warner@comcast.net>
There is a member of the osel_s structure called 'flg'
that is used to reflect whether a particular filter is
one of inclusion or exclusion (negation). So by golly,
from now on we'll refer to it as 'inc', and not 'flg'!
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit involves very little content change and is
more concerned with better formatting for readability.
Signed-off-by: Jim Warner <james.warner@comcast.net>
When the command line sort override provisions (-o/-O)
were added, the usage text was modified to keep within
an 80 column terminal but the nls hint didn't keep up.
Reference(s):
commit 407d1fc8f2
Signed-off-by: Jim Warner <james.warner@comcast.net>
Two too many of these '=' (cooks) spoiled top's broth.
There exists an unintentional variation on the classic
error: off-by-one. When a negation symbol is used with
top's new relational 'other filter' provision, one too
many 'matches' are excluded. This happened because top
covered only 2 of the 3 potential strcmp return codes.
When the strings were equal, they were simply dropped.
So this patch will uninvent that particular variation!
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 2c2c5f5cd2
Signed-off-by: Jim Warner <james.warner@comcast.net>
When I originally entertained thoughts of maybe adding
relational operators to the new 'Other Filter' feature
the programming challenges seemed just too great. Yet,
when Jaromir suggests its desirability it now suddenly
becomes a reality. Another of life's little mysteries!
At any rate what was already an extremely powerful new
feature is even better by several orders of magnitude!
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
References:
http://www.freelists.org/post/procps/top-beyond-infinity,1
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit provides the hard copy support for our new
'Other Filter' feature. The man document contains some
potentially useful examples and it will be interesting
to see what use this new tool is put to in the future.
(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 represents the extension of user filtering
based on inclusion or exclusion. However where 'U'/'u'
filtering provides an either/or choice, this extension
offers multiple choices applicable to multiple fields.
The 'inclusion' and 'exclusion' criteria can be freely
combined making a powerful tool to fine tune a display
and avoid clutter associated with uninteresting tasks.
I'm convinced it offers unimagined future flexibility!
(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-over-the-top,22http://www.freelists.org/post/procps/top-over-the-top,8
Signed-off-by: Jim Warner <james.warner@comcast.net>
While it's only documented (so far) in commit text and
an occasional email I've tried to maintain some coding
standards primarily for reference/navigation purposes.
They also served, I felt, as useful mental challenges.
Someday I will get around to formerly documenting them
but in the meantime here are the ones for this commit:
. functions are grouped into logical (i hope) sections
. functions & sections are ordered to avoid prototypes
. function names are alphabetical within every section
Thus, given those constraints/objectives, and in order
to prepare for an upcoming Other_Filter feature, a few
things had to be renamed and rearranged. Plus a couple
of other (unrelated) tweaks were made for consistency.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 270e8e7eebhttp://www.freelists.org/post/procps/PATCH-12-top-restore-terminal-state-on-exit,4
Signed-off-by: Jim Warner <james.warner@comcast.net>
if top is suspended while on the 2nd level help screen
the <Enter> key is no longer honored. Thus, users must
use <Esc> to exit help and return to the main display.
Also, line input that was only partially complete when
suspended would still require one additional keystroke
before the read was aborted and the display refreshed.
Lastly, some user interactions might require two input
lines before an operation can be considered completed.
Thus the 2nd line offers another opportunity for users
to suspend top. Resumption would require an extra key.
These issues stem from 2 recent enhancements: preserve
the user context when signaled; complete input editing
with cursor movement keys, insert/overtype modes, etc.
With this patch, the <Enter> key is once again honored
on help screen #2 and partial reads are now completed.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
bug reported
http://www.freelists.org/post/procps/top-over-the-top,25
response to ^Z (partial solution)
commit 5c3fffcf28
line input editing
commit 477b10c0bd
preserve context with SIGWINCH
commit ba9092ad83
Signed-off-by: Jim Warner <james.warner@comcast.net>
After revisiting the issue of a new field, combining 2
existing fields (RES and SWAP), I've decided it indeed
makes sense. After all, with the vastly expanded field
capability and the ease of adding new fields, it would
save some precious horizontal screen real estate while
also eliminating some mental/manual user calculations.
(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-enhancements-i-hopehttp://www.freelists.org/post/procps/top-regression-reports
Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.1 | 23 ++++++++++++++---------
top/top.c | 14 ++++++++++++--
top/top.h | 6 ++++++
top/top_nls.c | 3 +++
4 files changed, 35 insertions(+), 11 deletions(-)
This commit just gathers all the logic associated with
resetting/normalizing a single window in one function.
In the future, should the window structure be expanded
to support added functionality, the act of maintaining
it will have been made a little bit easier, hopefully.
(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>
When true line input editing with paste capability was
was re-introduced in the commit below, the concept for
the distinct insert/overtype mode was also introduced.
But such a distinction did not survive an <Enter> key.
With this commit, the cursor state is made persistent.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 477b10c0bd
Signed-off-by: Jim Warner <james.warner@comcast.net>
When both 'kill' and 'renice' commands were changed to
provide a default pid, the 'n' command (maximum tasks)
should have also changed to continue to accept just an
<Enter> key under the get_int function's new protocol.
This patch corrects that behavior, accepting no input.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 39f4067c66
Signed-off-by: Jim Warner <james.warner@comcast.net>
The original implementation of input line recall keeps
strings in the order established when initially added.
With this commit, that has been changed so any matched
string moves to the top of the saved input line stack.
[ well technically not the top since that's occupied ]
[ by an 'empty' string which serves multiple masters ]
Thus, the most frequently referenced strings over time
will percolate up and remain the most easily recalled.
But just in case anybody prefers the strict historical
ordering, a #define can restore the original behavior.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 2efe275512
Signed-off-by: Jim Warner <james.warner@comcast.net>
Now that line input offers users full editing freedom,
if top were to be suspended after issuing a prompt for
input, upon resumption an extra keystroke is necessary
to satisfy the outstanding read & refresh the display.
With this patch that extra keystroke is not necessary.
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit 477b10c0bd
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch fixes the single stinkin' source line which
was responsible for breaking the top idle-mode toggle.
Without this change, either 'u' or 'U' must be invoked
just once before the 'i' command would show something.
(yes, everything's perfectly justified once again but)
(i'm not very happy over the need for this damn patch)
Reference(s):
commit d04297843f
Signed-off-by: Jim Warner <james.warner@comcast.net>
With this commit, users can now retrieve previous line
input for re-editing and/or re-input using the Up/Down
arrow keys (or their aliases). This mirrors the 'bash'
or 'less' interface and represents a major enhancement
achieved via a somewhat minor impact to our code base.
[ 33 lines of code, 5 closing braces & some comments ]
[ all in 1 function, when TERMIOS_ONLY isn't defined ]
Currently, the upper limit for such recallable strings
has been set at 50 but that could be easily increased.
(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 patch changes the TERMIO_PROXY define back to the
former TERMIOS_ONLY thus changing the top default too.
Plus we can now use true line input editing while also
retaining paste capability. That former native termios
support provided only a limited destructive backspace.
Now we exploit the Left/Right arrow keys, Home/End and
Delete. Plus, the Insert key can toggle overtype mode!
[ The stage is now set for a really huge improvement ]
[ to any user input terminated with the <Enter> key. ]
[ So please stay tuned for the next patch to arrive! ]
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
commit fa21a6ca81
Signed-off-by: Jim Warner <james.warner@comcast.net>
With this commit top can now display users which match
a user id/name or just those users which do not match.
The distinction is based on the presence or absence of
a leading exclamation point '!' (C negation operator).
(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)
Reference(s):
Wishlist, http://bugs.debian.org/682086
Signed-off-by: Jim Warner <james.warner@comcast.net>
Lately, top has begun to rely more and more on dynamic
memory allocations rather than the static buffers that
were found in many of its structures. This was perhaps
most evident in the increasing use of the strdup call.
This commit trades that function call for the internal
equivalent which will protect us from malloc failures.
(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 corrects one reference to 'decimal place'.
Even though a running top supports a delay interval of
unlimited precision, and a delay interval of thousands
of a second in the rcfile, we intentionally imply that
any delay interval is limited to tenths of a sec only.
Later in the man document, in section 7a, one finds an
admission that a user can set any desired delay value.
(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/tt,4
Signed-off-by: Jim Warner <james.warner@comcast.net>
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>
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>
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>
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>
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>
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>
This section purported to list fields in alphabetical
order, but this was not always true.
With this commit, strict ascii collating sequence is
now observed.
Signed-off-by: Jim Warner <james.warner@comcast.net>
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>
All warnings where about unnecessary quoting. The scriptlet
below will tell what was wrong.
for I in ./top/top.1 ./ps/ps.1 ./*.[0-9]; do
echo "== $I warnings =="
man --warnings=all $I > /dev/null
done
This should probably be turned to 'make check' script.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Since its inception top has provided for monitoring
only specific process ids via the -p command line
switch. This provision has also embraced the top
process itself, even though its pid wasn't yet known.
This commit simply documents the special zero value,
which would otherwise be an invalid process id.
Signed-off-by: Jim Warner <james.warner@comcast.net>
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>
Admittedly, top referred to memory quantities in
a variety of non-standard ways. This commit brings
the program and supporting documentation into strict
compliance with IEC standard binary names.
According to wikipedia, as of 2012 this IEC standard
was still not in widespread use. However, I'm making
this change now for the anal-retentive among us.
Reference:
http://en.wikipedia.org/wiki/Megabyte
Reported by: Roman Mamedov <rm@romanrm.ru>
Bug-Debian: http://bugs.debian.org/662786
Signed-off-by: Jim Warner <james.warner@comcast.net>
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>
All top.h defines were lumped together as:
'Development/Debugging defines'
This commit establishes this new category:
'Defines represented in configure.ac'
And that new category now contains OOMEM_ENABLE,
which enables the SuSE out-of-memory additions
Signed-off-by: Jim Warner <james.warner@comcast.net>
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>
This patch adds the -p option to the uptime(1) command, which changes
the uptime displayed from something like:
10:35:52 up 2:33, 1 user, load average: 1.69, 1.65, 1.63
to:
up 2 hours, 33 minutes
I originally implemented this as the up(1) program about 14 years ago.
In 2008 or 2009, I created a patch for procps to add this functionality
to uptime and submitted it to the project. Never heard from the
project and no new releases of procps had been made. Then I found out
about this project and decided to port my patch to it. So here it is.
This is really just for fun. There is no real technical reason to
have this functionality. But even now, 14 years later, I still get
emails asking where the source code for up is. So I thought it would
be nice for the uptime command on Linux to sport the up functionality
by default.
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>
Due to a poorly constructed temporary fprintf
used during development, an earlier commit went
a little too far in its computations. The net
result was the code looked nice but actually
accomplished nothing.
It is the /proc/stat line 1 (summary line)
whose tics must be used in establishing the
threshold boundary. And that calculation
need be performed just once per frame.
This commit ensures one threshold calculation
per delay interval no matter how many cpus
are ultimately displayed.
It also corrects scalability by factoring in
the total number of online processors.
Reference:
commit 9e7dd43ab7
Along the way to width override support (-w switch),
this top began clearing the screen far more often
than his predecessor. In fact, it happend with each
user keystroke.
This commit dramatically reduces those occurances.
The screen will now be cleared only when an actual
SIGWINCH is received.
Thanks for identifying this flaw belongs to:
James Cloos, cloos@jhcloos.com
References:
http://www.freelists.org/post/procps/Merge-request
Blame: c2dcbef482
Author: Jim Warner <james.warner@comcast.net>
Date: Thu May 26 11:33:32 2011 +0200
subject: added output width/height override support to top, + misc
The original approach to potential % CPU distortion due
to Nehalem type cores being turned off completely when
idle worked ok until the user typed something.
At that point, elapsed tics would no longer equal the
calculated value producing an undesirable 100% idle
condition until the next update or <Enter/Space> key.
This commit employs actual elapsed tics in determining
whether a cpu should be considered idle and thus makes
top's individual cpu display immune to user keystrokes.
This patch provides for cpu cores which can be turned
off completely when idle (Nehalem, etc.) thus registering
very few or no tics since the last update cycle.
When CPU_ZEROTICS is not defined (the default), any
displayed cpu with less than a certain amount of total
tics will show as 100% idle. That amount is tempered
by the delay interval and total number of cpus.
This commit also satisfies the Debian 'top_nohz' patch
(11/24/09) in a slightly more efficient manner. That
patch concerned kernels built with CONFIG_NO_HZ.
Reference:
http://www.freelists.org/post/procps/CStates-handling-new-switch,4
Prior to this patch, top was able to handle any hotplugged
cpus *added* to the system in two distinct ways.
1) Newly added cpus would be detected by sysinfo_refresh
calling the library's cpuinfo function, which occurs
at most every 5 minutes.
2) The user could force a refresh using either the
<Enter> or <Space> keys.
Unfortunately, the *loss* of a cpu would produce an early
exit due to a /proc/stat read failure. Such a failure
can be produced in the following way:
sudo echo 0 > /sys/devices/system/cpu/cpu??/online
This commit allows top to tolerate the loss of cpus.
It also provides for more efficient CPU_t management,
especially for massively parallel cpu environments.
Note: Changes to the cpu compliment can produce a single
cycle distortion of cpu percentages. Such distortion is
most visible when each cpu is being displayed. It can
be eliminated with a forced refresh via <Enter>/<Space>.
With the introduction of the 'locate string' provisions,
the precedent for calling tertiary helper functions from
secondary do_key helper functions was established.
This commit simply migrates some additional keys out of
the do_key function itself and into the more generalized
key table.
Normally, when the chosen sort column is displayed via the
'x' command toggle the entire column is highlighted. And
while this version of top substantially reduced the cost
of such highlighting, a small pathlength increase remained.
The USE_X_COLHDR define was an experimental alternative which
eliminated all recurring runtime costs for such emphasis by
highlighting the column header, not the entire column.
The previous implementation required colors to be turned on
(the 'z' toggle) for such highlighting to be visible. This
commit extends column header emphasis to include monochrome
displays as well.
Reference:
http://www.freelists.org/post/procps/post-nls-merge,6
Since its inception, this top has improperly handled an
empty HOME environment variable. Under those conditions
a path to the root directory would have been constructed.
That caused no real harm upon startup since the display
defaults would have been employed. However, except for
root, it would have been impossible to save the rc file.
This commit keeps the promise made in the documentation.
This commit addresses a long standing buglet (debian #441166) which
surfaces when the display mode is switched between task and threads.
An extra procps refresh is now forced upon such a transition which
parallels the approach used at startup for the exact same reason.
Reference: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=441166
Some of the latest changes to Makefile.am files are missing.
This patch restores the LOCALEDIR variable, among others,
and dispenses with the include directives in the ps/ and top/
subdirectories since they're no longer needed.
This commit corrects some outdated programmer comments.
Additionally, certain nls justifications might become
increasingly obscure with the passage of time so some
previous nls commit text has been added as comments.
This patch represents the final resting place for miscellaneous
changes not otherwise encountered or for which the resolution
was incomplete or incorrect.
The gettext documentation leads one to believe that
a printf type call is necessary for gettext string
extraction. That turns out to be misleading and
all one really needs is the runtime gettext string
address resolution.
Thus, we can avoid our original snprintf/strdup
overhead and establish an address for the original
or translated string just by issuing the _() macro.
We create these nls string tables so that:
1) top avoids the overhead of repeated
runtime function calls
2) we can control the order of top's
strings in the .pot file
3) translator comments don't obscure
and clutter the main program
Until this patch, top had used some strings with
special escape sequences to produce colors, normal
text, bold text, etc. They took the following form,
explained by an excerpt from program comments:
...
Our special formatting consists of:
"some text <_delimiter_> some more text <_delimiter_>...\n"
Where <_delimiter_> is a single byte in the range of:
\001 through \010 (in decimalizee, 1 - 8)
and is used to select an 'attribute' from a capabilities table
which is then applied to the *preceding* substring.
...
Unfortunately, these nonprinting values revealed
insurmountable inconsistencies in both the front-end
and back-end translation tools.
The xgettext (extraction) program would take those
special escapes, convert them and then output raw
binary values. Thus the .pot file would contain
lots of unprintable stuff making it unreadable.
If the following was added to po/Makevars, most of
those special escapes would be preserved in their
escape notation:
XGETTEXT_OPTIONS = ... --escape
But two escapes were converted from octal notation
and there was no way to prevent it:
\007 --> \a
\010 --> \b
After a pass through the msginit program, most of
the escapes were reconverted to raw binary values
making translation impossible. There was no
"--escape" option for the back-end programs like
there was for xgettext.
But the real killer was the escape \004, also used
in some of top's special strings. This value would
be silently accepted by xgettext, only to produce
the following fatal error in back-end programs like
msginit, msgfmt and msgen:
.pot:2647: context separator <EOT> within string
To quote from one of the references below:
"Would you create a suite of tools that silently
allow what is destined to become a fatal error
to pass unnoticed?"
So the bottom line was: top's special strings, in
use for the past nine years, had to be redesigned.
References:
http://www.freelists.org/post/procps/procpsng-nls-support,11http://www.freelists.org/post/procps/procpsng-nls-support,14
summary of changes:
. adopted relative paths to 'include' and 'proc'
dirs so that stand alone compiles are made
easier and no one need guess their locations
. corrected several names for enums and macro
usage reflecting fmt vs. txt
. expanded all octal escape sequences to a full
3 digits since one already required 3 digits
. finalized translator hints (for now)
programming note:
as an aside, by not including an argument for
the gettext --add-comments, any preceeding c
style comment will be propagated to the .pot
file, if the gettext macro isn't empty.
/* Need Not Say 'TRANSLATORS' ...
snprintf(buf, sizeof(buf), "%s", _( // unseen
/* Translator Hint: ...
snprintf(buf, sizeof(buf), "%s", _("" // seen