When the calibrate_fields function was broken up for
mainainability, an obscure regression was introduced.
For the resulting bug to affect the display, all of
the following conditions would have to be met:
. USE_X_COLHDR was not defined
. column highlighting had been turned on
. many, perhaps all, fields were displayable
. the user then typed the <End> key
. and the current sort column just happened to
be immediately to the left of the left-most
visible field
This patch corrects for that remote possibility.
Reference:
commit d0e16acf15
Signed-off-by: Jim Warner <james.warner@comcast.net>
The short option for --inverse is disabled for pkill, but long option
works just in case someone will find that piece of functionality usable.
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558044#67
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
Checking for linux kernel version 2.7.0 is meaningless now when 3.0.0
is out.
Reported-By: Christian Hofstaedtler
Bug-Debian: http://bugs.debian.org/635553
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The -d, --differences switch(s) can use optional argument that was
not documented earlier.
Reported-By: Marian Sigler <m@qjym.de>
Bug-Debian: http://bugs.debian.org/597021
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The option -v does not make much sense in pkill context.
Reported-By: "Jason A. Spiro" <jasonspiro4@gmail.com>
Bug-Debian: http://bugs.debian.org/558044
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
I as user often try to pkill something, notice that program did not
die and pkill again with signal -9. Before this commit previous one
could not add signal at the end of command line, as the signal
definition had to be first argument, which was annoying.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The c++ comments e.g. // should not be used in c code. Additionally
white spaces are converted to tabs as a small clean up.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Command skill accepted earlier command name as argument. This did
not work since commit 991b8a94f0.
Reported-By: "Anne C. Hanna" <orion@ugcs.caltech.edu>
Bug-Debian: http://bugs.debian.org/659038
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The pwdx check expected error message, which where in use for only
short period of time. The old message was put in place in commit
9d47cb0c38
The vmstat issue was triggered by 'sr0' cdrom device, which gives
following unexpected output. Fix simply ignores partitions which has
zero activity. Besides such partitions probably would not apply as
good candidate of -p option anyway.
$ vmstat -p sr0
Partition was not found
Reported-By: Moritz Muehlenhoff <jmm@debian.org>
Bug-Debian: http://bugs.debian.org/656508
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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.
pmap.c:436 main(59) error: we previously assumed 'arg1' could be null (see line 427)
pmap.c:136:3: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:142:4: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:150:2: warning: return discards 'const' qualifier from pointer target type [enabled by default]
pmap.c:300:8: warning: assignment discards 'const' qualifier from pointer target type [enabled by default]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Newer ncurses install pkg-config files, so search those first. If they
aren't found, fall back to existing detection logic.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
The third arg is for "the user has specified some flag", not "the user
has disabled things", so use $withval.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
The first check for ncurses is for the non-wide variant, so drop the "w".
The wide version gets checked later on based on watch8bit.
Signed-off-by: Samuli Suominen <ssuominen@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
pgrep.c: In function 'main':
pgrep.c:793:4: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat]
vmstat.c: In function 'diskpartition_format':
vmstat.c:382:9: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'long long unsigned int' [-Wformat]
vmstat.c:408:10: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'long long unsigned int' [-Wformat]
w.c: In function 'main':
w.c:394:4: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long unsigned int' [-Wformat]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
pmap.c:300:8: warning: assignment discards 'const' qualifier
from pointer target type [enabled by default]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Add new flags to watch (-g/--chgexit) so that it exits when the
output changes. This is useful in builds and shell scripts, for
example when deploying webapps to block the remainder of the
deployment steps until after the webapp starts.
e.g. watch --chgexit curl http://foo/bar
Clean the global list of symbols contain only functions and variables which
are being called from library. The removed symbols are internal for the
library, which means they can be changed without changes to programs using
the library. This clean up should help incoming libprocps clean up work.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This code currently uses error_at_line() from error.h, so pull it in.
Long term, this might get moved to c.h as a local helper on err.h,
but I have no idea.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Fix the build warnings:
sig.c:227:5: warning: implicit declaration of function 'toupper' [-Wimplicit-function-declaration]
sig.c:231:3: warning: implicit declaration of function 'isdigit' [-Wimplicit-function-declaration]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Fixes build warning:
watch.c:682:3: warning: implicit declaration of
function 'waitpid' [-Wimplicit-function-declaration]
Signed-off-by: Mike Frysinger <vapier@gentoo.org>