2011-03-31 16:45:12 +05:30
|
|
|
|
/* top.h - Header file: show Linux processes */
|
|
|
|
|
/*
|
2013-01-01 11:30:00 +05:30
|
|
|
|
* Copyright (c) 2002-2013, by: James C. Warner
|
2011-03-31 16:45:12 +05:30
|
|
|
|
* All rights reserved. 8921 Hilloway Road
|
|
|
|
|
* Eden Prairie, Minnesota 55347 USA
|
|
|
|
|
*
|
|
|
|
|
* This file may be used subject to the terms and conditions of the
|
|
|
|
|
* GNU Library General Public License Version 2, or any later version
|
|
|
|
|
* at your option, as published by the Free Software Foundation.
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU Library General Public License for more details.
|
|
|
|
|
*/
|
|
|
|
|
/* For contributions to this program, the author wishes to thank:
|
|
|
|
|
* Craig Small, <csmall@small.dropbear.id.au>
|
|
|
|
|
* Albert D. Cahalan, <albert@users.sf.net>
|
2011-10-12 00:32:59 +05:30
|
|
|
|
* Sami Kerola, <kerolasa@iki.fi>
|
2011-03-31 16:45:12 +05:30
|
|
|
|
*/
|
2002-05-30 09:14:46 +05:30
|
|
|
|
#ifndef _Itop
|
|
|
|
|
#define _Itop
|
2002-02-02 04:17:29 +05:30
|
|
|
|
|
2011-10-14 22:15:44 +05:30
|
|
|
|
#include "../proc/readproc.h"
|
2011-10-26 17:01:48 +05:30
|
|
|
|
|
2012-02-11 12:31:01 +05:30
|
|
|
|
/* Defines represented in configure.ac ----------------------------- */
|
|
|
|
|
//#define OOMEM_ENABLE /* enable the SuSE out-of-memory additions */
|
2013-01-29 11:30:00 +05:30
|
|
|
|
//#define SIGNALS_LESS /* favor reduced signal load over response */
|
2012-02-11 12:31:01 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Development/Debugging defines ----------------------------------- */
|
2011-04-14 02:38:14 +05:30
|
|
|
|
//#define ATEOJ_RPTHSH /* report on hash specifics, at end-of-job */
|
|
|
|
|
//#define ATEOJ_RPTSTD /* report on misc stuff, at end-of-job */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//#define CASEUP_HEXES /* show any hex values in upper case */
|
|
|
|
|
//#define CASEUP_SUFIX /* show time/mem/cnts suffix in upper case */
|
2012-02-03 11:30:00 +05:30
|
|
|
|
//#define CPU_ZEROTICS /* tolerate few tics when cpu off vs. idle */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//#define EQUCOLHDRYES /* yes, do equalize column header lengths */
|
2012-12-03 11:30:00 +05:30
|
|
|
|
//#define INSP_JUSTNOT /* don't smooth unprintable right margins */
|
top: add a flexible 'Inspect' capability
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>
2012-11-25 10:30:05 +05:30
|
|
|
|
//#define INSP_OFFDEMO /* disable demo screens, issue msg instead */
|
|
|
|
|
//#define INSP_SAVEBUF /* preserve 'Insp_buf' contents in a file */
|
|
|
|
|
//#define INSP_SLIDE_1 /* when scrolling left/right don't move 8 */
|
top: provide the means to adjust scaled process memory
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>
2012-12-14 11:30:00 +05:30
|
|
|
|
//#define NOBOOST_MEMS /* disable extra precision for mem fields */
|
|
|
|
|
//#define NOBOOST_PCNT /* disable extra precision for % fields */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
|
|
|
|
|
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
|
|
|
|
|
//#define PRETEND2_5_X /* pretend we're linux 2.5.x (for IO-wait) */
|
|
|
|
|
//#define PRETEND4CPUS /* pretend we're smp with 4 ticsers (sic) */
|
|
|
|
|
//#define PRETENDNOCAP /* use a terminal without essential caps */
|
2011-04-15 04:54:29 +05:30
|
|
|
|
//#define RCFILE_NOERR /* rcfile errs silently default, vs. fatal */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//#define RMAN_IGNORED /* don't consider auto right margin glitch */
|
2012-06-30 10:30:00 +05:30
|
|
|
|
//#define SCROLLVAR_NO /* disable intra-column horizontal scroll */
|
2012-04-11 14:41:12 +05:30
|
|
|
|
//#define STRINGCASENO /* case insenstive compare/locate versions */
|
top: correct loss of keystrokes paste capability
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: 045538e01b4588e33bacc1ac57abc799b6d24d7b
Reported by: sergio <mailbox@sergio.spb.ru>
Bug-Debian: http://bugs.debian.org/663334
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-03-12 22:42:12 +05:30
|
|
|
|
//#define TERMIO_PROXY /* true line editing, beyond native input */
|
2011-08-30 17:35:45 +05:30
|
|
|
|
//#define TREE_NORESET /* sort keys do NOT force forest view OFF */
|
2011-04-14 02:38:14 +05:30
|
|
|
|
//#define USE_X_COLHDR /* emphasize header vs. whole col, for 'x' */
|
2012-12-20 11:30:00 +05:30
|
|
|
|
//#define VALIDATE_NLS /* validate the integrity of all nls tbls */
|
2011-04-14 02:38:14 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*###### Notes, etc. ###################################################*/
|
|
|
|
|
|
2011-05-05 15:37:25 +05:30
|
|
|
|
/* The following convention is used to identify those areas where
|
2011-04-14 02:38:14 +05:30
|
|
|
|
adaptations for hotplugging are to be found ...
|
2011-05-05 15:37:25 +05:30
|
|
|
|
*** hotplug_acclimated ***
|
2011-10-28 20:58:37 +05:30
|
|
|
|
( hopefully libproc will also be supportive of our efforts ) */
|
2011-04-14 02:38:14 +05:30
|
|
|
|
|
2011-05-05 15:37:25 +05:30
|
|
|
|
/* For introducing inaugural cgroup support, thanks to:
|
2011-10-28 20:58:37 +05:30
|
|
|
|
Jan Gorig <jgorig@redhat.com> - April, 2011 */
|
2004-07-07 01:35:30 +05:30
|
|
|
|
|
2011-10-12 00:32:59 +05:30
|
|
|
|
/* For the motivation and path to nls support, thanks to:
|
2012-02-07 11:29:59 +05:30
|
|
|
|
Sami Kerola, <kerolasa@iki.fi> - December, 2011 */
|
2011-10-12 00:32:59 +05:30
|
|
|
|
|
|
|
|
|
/* There are still some short strings that may yet be candidates
|
|
|
|
|
for nls support inclusion. They're identified with:
|
2011-10-28 20:58:37 +05:30
|
|
|
|
// nls_maybe */
|
2002-02-02 04:17:29 +05:30
|
|
|
|
|
2012-02-11 02:45:15 +05:30
|
|
|
|
/* For initiating the topic of potential % CPU distortions due to
|
|
|
|
|
to kernel and/or cpu anomalies (see CPU_ZEROTICS), thanks to:
|
|
|
|
|
Jaromir Capik, <jcapik@redhat.com> - February, 2012 */
|
2012-02-07 11:29:59 +05:30
|
|
|
|
|
2002-10-19 02:45:49 +05:30
|
|
|
|
#ifdef PRETEND2_5_X
|
|
|
|
|
#define linux_version_code LINUX_VERSION(2,5,43)
|
|
|
|
|
#endif
|
2002-02-02 04:17:29 +05:30
|
|
|
|
|
2012-04-11 14:41:12 +05:30
|
|
|
|
#ifdef STRINGCASENO
|
|
|
|
|
// pretend as if #define _GNU_SOURCE
|
|
|
|
|
char *strcasestr(const char *haystack, const char *needle);
|
|
|
|
|
#define STRSTR strcasestr
|
|
|
|
|
#define STRCMP strcasecmp
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#else
|
2012-04-11 14:41:12 +05:30
|
|
|
|
#define STRSTR strstr
|
|
|
|
|
#define STRCMP strcmp
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#endif
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*###### Some Miscellaneous constants ##################################*/
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* The default delay twix updates */
|
|
|
|
|
#define DEF_DELAY 3.0
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
2011-07-14 16:46:02 +05:30
|
|
|
|
/* Length of time a message is displayed and the duration
|
|
|
|
|
of a 'priming' wait during library startup (in microseconds) */
|
2013-01-16 11:30:00 +05:30
|
|
|
|
#define MSG_USLEEP 1250000
|
|
|
|
|
#define LIB_USLEEP 150000
|
2004-07-07 01:35:30 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Specific process id monitoring support (command line only) */
|
|
|
|
|
#define MONPIDMAX 20
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
2011-05-26 15:03:32 +05:30
|
|
|
|
/* Output override minimums (the -w switch and/or env vars) */
|
|
|
|
|
#define W_MIN_COL 3
|
|
|
|
|
#define W_MIN_ROW 3
|
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Miscellaneous buffers with liberal values and some other defines
|
|
|
|
|
-- mostly just to pinpoint source code usage/dependancies */
|
|
|
|
|
#define SCREENMAX 512
|
|
|
|
|
/* the above might seem pretty stingy, until you consider that with every
|
2011-12-29 23:20:32 +05:30
|
|
|
|
field displayed the column header would be approximately 250 bytes
|
|
|
|
|
-- so SCREENMAX provides for all fields plus a 250+ byte command line */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#define CAPBUFSIZ 32
|
|
|
|
|
#define CLRBUFSIZ 64
|
|
|
|
|
#define PFLAGSSIZ 64
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#define SMLBUFSIZ 128
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#define MEDBUFSIZ 256
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#define LRGBUFSIZ 512
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#define OURPATHSZ 1024
|
|
|
|
|
#define BIGBUFSIZ 2048
|
2012-06-30 10:30:55 +05:30
|
|
|
|
/* in addition to the actual display data, our row might have to accommodate
|
2011-04-14 02:38:14 +05:30
|
|
|
|
many termcap/color transitions - these definitions ensure we have room */
|
|
|
|
|
#define ROWMINSIZ ( SCREENMAX + 4 * (CAPBUFSIZ + CLRBUFSIZ) )
|
|
|
|
|
#define ROWMAXSIZ ( SCREENMAX + 16 * (CAPBUFSIZ + CLRBUFSIZ) )
|
top: add a flexible 'Inspect' capability
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>
2012-11-25 10:30:05 +05:30
|
|
|
|
// minimum size guarantee for dynamically acquired 'readfile' buffer
|
|
|
|
|
#define READMINSZ 2048
|
2013-01-16 11:30:00 +05:30
|
|
|
|
// size of preallocated search string buffers, same as ioline()
|
top: highlight all regular search string(s) when found
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>
2012-12-08 11:30:00 +05:30
|
|
|
|
#define FNDBUFSIZ MEDBUFSIZ
|
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
2012-09-19 11:31:01 +05:30
|
|
|
|
// space between task fields/columns
|
|
|
|
|
#define COLPADSTR " "
|
|
|
|
|
#define COLPADSIZ ( sizeof(COLPADSTR) - 1 )
|
|
|
|
|
// continuation ch when field/column truncated
|
|
|
|
|
#define COLPLUSCH '+'
|
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
// support for keyboard stuff (cursor motion keystrokes, mostly)
|
|
|
|
|
#define kbd_ESC '\033'
|
|
|
|
|
#define kbd_SPACE ' '
|
2013-01-11 11:30:00 +05:30
|
|
|
|
#define kbd_UP 0x01
|
|
|
|
|
#define kbd_DOWN 0x02
|
|
|
|
|
#define kbd_RIGHT 0x03
|
|
|
|
|
#define kbd_LEFT 0x04
|
|
|
|
|
#define kbd_PGUP 0x05
|
|
|
|
|
#define kbd_PGDN 0x06
|
|
|
|
|
#define kbd_END 0x07
|
|
|
|
|
#define kbd_HOME 0x08
|
|
|
|
|
#define kbd_BKSP 0x09
|
|
|
|
|
#define kbd_ENTER 0x0a // this is also the real ^J
|
|
|
|
|
#define kbd_INS 0x0b
|
|
|
|
|
#define kbd_DEL 0x0c
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
2012-01-09 22:56:45 +05:30
|
|
|
|
/* Special value in Pseudo_row to force an additional procs refresh
|
|
|
|
|
-- used at startup and for task/thread mode transitions */
|
|
|
|
|
#define PROC_XTRA -1
|
|
|
|
|
|
2012-02-11 02:45:15 +05:30
|
|
|
|
#ifndef CPU_ZEROTICS
|
2012-02-09 11:29:59 +05:30
|
|
|
|
/* This is the % used in establishing the tics threshold below
|
|
|
|
|
which a cpu is treated as 'idle' rather than displaying
|
|
|
|
|
misleading state percentages */
|
|
|
|
|
#define TICS_EDGE 20
|
2012-02-11 02:45:15 +05:30
|
|
|
|
#endif
|
2012-02-09 11:29:59 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
/* ##### Enum's and Typedef's ############################################ */
|
|
|
|
|
|
|
|
|
|
/* Flags for each possible field (and then some) --
|
|
|
|
|
these MUST be kept in sync with the FLD_t Fieldstab[] array !! */
|
|
|
|
|
enum pflag {
|
|
|
|
|
P_PID = 0, P_PPD,
|
|
|
|
|
P_UED, P_UEN, P_URD, P_URN, P_USD, P_USN,
|
|
|
|
|
P_GID, P_GRP, P_PGD, P_TTY, P_TPG, P_SID,
|
|
|
|
|
P_PRI, P_NCE, P_THD,
|
|
|
|
|
P_CPN, P_CPU, P_TME, P_TM2,
|
|
|
|
|
P_MEM, P_VRT, P_SWP, P_RES, P_COD, P_DAT, P_SHR,
|
|
|
|
|
P_FL1, P_FL2, P_DRT,
|
2011-04-15 04:54:29 +05:30
|
|
|
|
P_STA, P_CMD, P_WCH, P_FLG, P_CGR,
|
2011-08-17 16:31:35 +05:30
|
|
|
|
P_SGD, P_SGN, P_TGD,
|
2011-05-18 14:03:44 +05:30
|
|
|
|
#ifdef OOMEM_ENABLE
|
2011-04-14 02:38:14 +05:30
|
|
|
|
P_OOA, P_OOM,
|
|
|
|
|
#endif
|
2012-07-01 10:30:22 +05:30
|
|
|
|
P_ENV,
|
2012-07-08 14:32:58 +05:30
|
|
|
|
P_FV1, P_FV2,
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#ifdef USE_X_COLHDR
|
|
|
|
|
// not really pflags, used with tbl indexing
|
|
|
|
|
P_MAXPFLGS
|
|
|
|
|
#else
|
2011-03-31 16:45:12 +05:30
|
|
|
|
// not really pflags, used with tbl indexing & col highlighting
|
|
|
|
|
P_MAXPFLGS, X_XON, X_XOF
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#endif
|
2011-03-31 16:45:12 +05:30
|
|
|
|
};
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
top: provide the means to adjust scaled process memory
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>
2012-12-14 11:30:00 +05:30
|
|
|
|
/* The scaling 'target' used with memory fields */
|
|
|
|
|
enum scale_enum {
|
2012-12-18 11:30:00 +05:30
|
|
|
|
SK_Kb, SK_Mb, SK_Gb, SK_Tb, SK_Pb, SK_Eb, SK_SENTINEL
|
2011-03-31 16:45:12 +05:30
|
|
|
|
};
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2013-01-16 11:30:00 +05:30
|
|
|
|
/* Used to manipulate (and document) the Frames_resize states */
|
|
|
|
|
enum resize_states {
|
|
|
|
|
RESIZ_clr, RESIZ_kbd, RESIZ_sig
|
|
|
|
|
};
|
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* This typedef just ensures consistent 'process flags' handling */
|
2011-08-30 17:35:45 +05:30
|
|
|
|
typedef unsigned char FLG_t;
|
2002-09-13 17:12:44 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* These typedefs attempt to ensure consistent 'ticks' handling */
|
2002-12-05 04:18:30 +05:30
|
|
|
|
typedef unsigned long long TIC_t;
|
|
|
|
|
typedef long long SIC_t;
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Sort support, callback function signature */
|
2002-12-05 04:18:30 +05:30
|
|
|
|
typedef int (*QFP_t)(const void *, const void *);
|
2002-09-13 17:12:44 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* This structure consolidates the information that's used
|
|
|
|
|
in a variety of display roles. */
|
2002-12-05 04:18:30 +05:30
|
|
|
|
typedef struct FLD_t {
|
2012-09-19 11:31:01 +05:30
|
|
|
|
int width; // field width, if applicable
|
top: provide the means to adjust scaled process memory
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>
2012-12-14 11:30:00 +05:30
|
|
|
|
int scale; // scaled target, if applicable
|
2012-09-19 11:31:01 +05:30
|
|
|
|
const int align; // the default column alignment flag
|
2002-12-05 04:18:30 +05:30
|
|
|
|
const QFP_t sort; // sort function
|
|
|
|
|
const int lflg; // PROC_FILLxxx flag(s) needed by this field
|
|
|
|
|
} FLD_t;
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#ifdef OFF_HST_HASH
|
2012-07-08 14:32:58 +05:30
|
|
|
|
/* This structure supports 'history' processing and records the
|
|
|
|
|
bare minimum of needed information from one frame to the next --
|
2011-03-31 16:45:12 +05:30
|
|
|
|
we don't calc and save data that goes unused like the old top. */
|
2002-12-05 04:18:30 +05:30
|
|
|
|
typedef struct HST_t {
|
2011-03-31 16:45:12 +05:30
|
|
|
|
TIC_t tics; // last frame's tics count
|
2012-07-08 14:32:58 +05:30
|
|
|
|
unsigned long maj, min; // last frame's maj/min_flt counts
|
|
|
|
|
int pid; // record 'key'
|
2002-12-05 04:18:30 +05:30
|
|
|
|
} HST_t;
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#else
|
2012-07-08 14:32:58 +05:30
|
|
|
|
/* This structure supports 'history' processing and records the
|
|
|
|
|
bare minimum of needed information from one frame to the next --
|
2011-03-31 16:45:12 +05:30
|
|
|
|
we don't calc and save data that goes unused like the old top nor
|
|
|
|
|
do we incure the overhead of sorting to support a binary search
|
|
|
|
|
(or worse, a friggin' for loop) when retrieval is necessary! */
|
|
|
|
|
typedef struct HST_t {
|
|
|
|
|
TIC_t tics; // last frame's tics count
|
2012-07-08 14:32:58 +05:30
|
|
|
|
unsigned long maj, min; // last frame's maj/min_flt counts
|
|
|
|
|
int pid; // record 'key'
|
|
|
|
|
int lnk; // next on hash chain
|
2011-03-31 16:45:12 +05:30
|
|
|
|
} HST_t;
|
|
|
|
|
#endif
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2012-02-01 11:30:00 +05:30
|
|
|
|
/* These 2 structures store a frame's cpu tics used in history
|
|
|
|
|
calculations. They exist primarily for SMP support but serve
|
2011-03-31 16:45:12 +05:30
|
|
|
|
all environments. */
|
2012-02-01 11:30:00 +05:30
|
|
|
|
typedef struct CT_t {
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* other kernels: u == user/us, n == nice/ni, s == system/sy, i == idle/id
|
|
|
|
|
2.5.41 kernel: w == IO-wait/wa (io wait time)
|
|
|
|
|
2.6.0 kernel: x == hi (hardware irq time), y == si (software irq time)
|
|
|
|
|
2.6.11 kernel: z == st (virtual steal time) */
|
2012-02-01 11:30:00 +05:30
|
|
|
|
TIC_t u, n, s, i, w, x, y, z; // as represented in /proc/stat
|
2012-02-11 02:45:15 +05:30
|
|
|
|
#ifndef CPU_ZEROTICS
|
2012-02-09 11:29:59 +05:30
|
|
|
|
SIC_t tot; // total from /proc/stat line 1
|
2012-02-11 02:45:15 +05:30
|
|
|
|
#endif
|
2012-02-01 11:30:00 +05:30
|
|
|
|
} CT_t;
|
2002-12-05 04:18:30 +05:30
|
|
|
|
|
2012-02-01 11:30:00 +05:30
|
|
|
|
typedef struct CPU_t {
|
|
|
|
|
CT_t cur; // current frame's cpu tics
|
|
|
|
|
CT_t sav; // prior frame's cpu tics
|
2012-02-07 11:29:59 +05:30
|
|
|
|
#ifndef CPU_ZEROTICS
|
2012-02-09 11:29:59 +05:30
|
|
|
|
SIC_t edge; // tics adjustment threshold boundary
|
2012-02-07 11:29:59 +05:30
|
|
|
|
#endif
|
2012-02-01 11:30:00 +05:30
|
|
|
|
int id; // the cpu id number (0 - nn)
|
|
|
|
|
} CPU_t;
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
/* /////////////////////////////////////////////////////////////// */
|
|
|
|
|
/* Special Section: multiple windows/field groups --------------- */
|
|
|
|
|
/* ( kind of a header within a header: constants, types & macros ) */
|
|
|
|
|
|
|
|
|
|
#define CAPTABMAX 9 /* max entries in each win's caps table */
|
|
|
|
|
#define GROUPSMAX 4 /* the max number of simultaneous windows */
|
|
|
|
|
#define WINNAMSIZ 4 /* size of RCW_t winname buf (incl '\0') */
|
|
|
|
|
#define GRPNAMSIZ WINNAMSIZ+2 /* window's name + number as in: '#:...' */
|
|
|
|
|
|
|
|
|
|
/* The Persistent 'Mode' flags!
|
|
|
|
|
These are preserved in the rc file, as a single integer and the
|
|
|
|
|
letter shown is the corresponding 'command' toggle */
|
|
|
|
|
// 'View_' flags affect the summary (minimum), taken from 'Curwin'
|
|
|
|
|
#define View_CPUSUM 0x008000 // '1' - show combined cpu stats (vs. each)
|
|
|
|
|
#define View_LOADAV 0x004000 // 'l' - display load avg and uptime summary
|
|
|
|
|
#define View_STATES 0x002000 // 't' - display task/cpu(s) states summary
|
|
|
|
|
#define View_MEMORY 0x001000 // 'm' - display memory summary
|
|
|
|
|
#define View_NOBOLD 0x000008 // 'B' - disable 'bold' attribute globally
|
|
|
|
|
#define View_SCROLL 0x080000 // 'C' - enable coordinates msg w/ scrolling
|
|
|
|
|
// 'Show_' & 'Qsrt_' flags are for task display in a visible window
|
|
|
|
|
#define Show_COLORS 0x000800 // 'z' - show in color (vs. mono)
|
|
|
|
|
#define Show_HIBOLD 0x000400 // 'b' - rows and/or cols bold (vs. reverse)
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#define Show_HICOLS 0x000200 // 'x' - show sort column emphasized
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#define Show_HIROWS 0x000100 // 'y' - show running tasks highlighted
|
|
|
|
|
#define Show_CMDLIN 0x000080 // 'c' - show cmdline vs. name
|
|
|
|
|
#define Show_CTIMES 0x000040 // 'S' - show times as cumulative
|
|
|
|
|
#define Show_IDLEPS 0x000020 // 'i' - show idle processes (all tasks)
|
|
|
|
|
#define Show_TASKON 0x000010 // '-' - tasks showable when Mode_altscr
|
2011-08-30 17:35:45 +05:30
|
|
|
|
#define Show_FOREST 0x000002 // 'V' - show cmd/cmdlines with ascii art
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#define Qsrt_NORMAL 0x000004 // 'R' - reversed column sort (high to low)
|
2012-09-20 11:31:01 +05:30
|
|
|
|
#define Show_JRSTRS 0x040000 // 'j' - right justify "string" data cols
|
|
|
|
|
#define Show_JRNUMS 0x020000 // 'J' - right justify "numeric" data cols
|
2011-03-31 16:45:12 +05:30
|
|
|
|
// these flag(s) have no command as such - they're for internal use
|
2012-09-19 11:31:01 +05:30
|
|
|
|
#define INFINDS_xxx 0x010000 // build rows for find_string, not display
|
2012-04-11 14:41:12 +05:30
|
|
|
|
#define EQUWINS_xxx 0x000001 // rebalance all wins & tasks (off i,n,u/U)
|
2013-01-04 11:30:00 +05:30
|
|
|
|
#ifndef USE_X_COLHDR
|
|
|
|
|
#define NOHICOL_xxx 0x100000 // must restrict Show_HICOLS temporarily
|
|
|
|
|
#endif
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
// Default flags if there's no rcfile to provide user customizations
|
|
|
|
|
#define DEF_WINFLGS ( View_LOADAV | View_STATES | View_CPUSUM | View_MEMORY \
|
2012-09-20 11:31:01 +05:30
|
|
|
|
| Show_HIBOLD | Show_HIROWS | Show_IDLEPS | Show_TASKON | Show_JRNUMS \
|
|
|
|
|
| Qsrt_NORMAL )
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
/* These are used to direct wins_reflag */
|
|
|
|
|
enum reflag_enum {
|
|
|
|
|
Flags_TOG, Flags_SET, Flags_OFF
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* These are used to direct win_warn */
|
|
|
|
|
enum warn_enum {
|
|
|
|
|
Warn_ALT, Warn_VIZ
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* This type helps support both a window AND the rcfile */
|
2002-12-05 04:18:30 +05:30
|
|
|
|
typedef struct RCW_t { // the 'window' portion of an rcfile
|
2012-03-05 22:52:33 +05:30
|
|
|
|
int sortindx, // sort field, represented as a procflag
|
|
|
|
|
winflags, // 'view', 'show' and 'sort' mode flags
|
2002-12-05 04:18:30 +05:30
|
|
|
|
maxtasks, // user requested maximum, 0 equals all
|
|
|
|
|
summclr, // color num used in summ info
|
|
|
|
|
msgsclr, // " in msgs/pmts
|
|
|
|
|
headclr, // " in cols head
|
|
|
|
|
taskclr; // " in task rows
|
|
|
|
|
char winname [WINNAMSIZ], // window name, user changeable
|
|
|
|
|
fieldscur [PFLAGSSIZ]; // fields displayed and ordered
|
|
|
|
|
} RCW_t;
|
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* This represents the complete rcfile */
|
|
|
|
|
typedef struct RCF_t {
|
top: honor the restrictive, crufty old top rcfile
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>
2012-03-01 11:29:59 +05:30
|
|
|
|
char id; // rcfile version id
|
2002-12-05 04:18:30 +05:30
|
|
|
|
int mode_altscr; // 'A' - Alt display mode (multi task windows)
|
|
|
|
|
int mode_irixps; // 'I' - Irix vs. Solaris mode (SMP-only)
|
2011-03-31 16:45:12 +05:30
|
|
|
|
float delay_time; // 'd'/'s' - How long to sleep twixt updates
|
2002-12-05 04:18:30 +05:30
|
|
|
|
int win_index; // Curwin, as index
|
2011-03-31 16:45:12 +05:30
|
|
|
|
RCW_t win [GROUPSMAX]; // a 'WIN_t.rc' for each window
|
2012-09-21 11:31:01 +05:30
|
|
|
|
int fixed_widest; // 'X' - wider non-scalable col addition
|
2012-12-14 11:30:00 +05:30
|
|
|
|
int summ_mscale; // 'E' - scaling of summary memory values
|
top: provide the means to adjust scaled process memory
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>
2012-12-14 11:30:00 +05:30
|
|
|
|
int task_mscale; // 'e' - scaling of process memory values
|
|
|
|
|
int zero_suppress; // '0' - suppress scaled zeros toggle
|
2002-12-05 04:18:30 +05:30
|
|
|
|
} RCF_t;
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* This structure stores configurable information for each window.
|
|
|
|
|
By expending a little effort in its creation and user requested
|
2012-06-30 10:30:55 +05:30
|
|
|
|
maintenance, the only real additional per frame cost of having
|
2011-03-31 16:45:12 +05:30
|
|
|
|
windows is an extra sort -- but that's just on pointers! */
|
|
|
|
|
typedef struct WIN_t {
|
2011-04-15 04:54:29 +05:30
|
|
|
|
FLG_t pflgsall [PFLAGSSIZ], // all 'active/on' fieldscur, as enum
|
|
|
|
|
procflgs [PFLAGSSIZ]; // fieldscur subset, as enum
|
|
|
|
|
RCW_t rc; // stuff that gets saved in the rcfile
|
|
|
|
|
int winnum, // a window's number (array pos + 1)
|
|
|
|
|
winlines, // current task window's rows (volatile)
|
|
|
|
|
maxpflgs, // number of displayed procflgs ("on" in fieldscur)
|
2011-03-31 16:45:12 +05:30
|
|
|
|
totpflgs, // total of displayable procflgs in pflgsall array
|
|
|
|
|
begpflg, // scrolled beginning pos into pflgsall array
|
|
|
|
|
endpflg, // scrolled ending pos into pflgsall array
|
|
|
|
|
begtask, // scrolled beginning pos into Frame_maxtask
|
2012-06-30 10:30:00 +05:30
|
|
|
|
#ifndef SCROLLVAR_NO
|
|
|
|
|
varcolbeg, // scrolled position within variable width col
|
|
|
|
|
#endif
|
2011-04-15 04:54:29 +05:30
|
|
|
|
varcolsz, // max length of variable width column(s)
|
|
|
|
|
usrseluid, // validated uid for 'u/U' user selection
|
|
|
|
|
usrseltyp, // the basis for matching above uid
|
|
|
|
|
hdrcaplen; // column header xtra caps len, if any
|
2011-03-31 16:45:12 +05:30
|
|
|
|
char capclr_sum [CLRBUFSIZ], // terminfo strings built from
|
|
|
|
|
capclr_msg [CLRBUFSIZ], // RCW_t colors (& rebuilt too),
|
|
|
|
|
capclr_pmt [CLRBUFSIZ], // but NO recurring costs !
|
|
|
|
|
capclr_hdr [CLRBUFSIZ], // note: sum, msg and pmt strs
|
|
|
|
|
capclr_rowhigh [CLRBUFSIZ], // are only used when this
|
2011-04-15 04:54:29 +05:30
|
|
|
|
capclr_rownorm [CLRBUFSIZ], // window is the 'Curwin'!
|
|
|
|
|
cap_bold [CAPBUFSIZ], // support for View_NOBOLD toggle
|
|
|
|
|
grpname [GRPNAMSIZ], // window number:name, printable
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#ifdef USE_X_COLHDR
|
2011-04-15 04:54:29 +05:30
|
|
|
|
columnhdr [ROWMINSIZ], // column headings for procflgs
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#else
|
2011-04-15 04:54:29 +05:30
|
|
|
|
columnhdr [SCREENMAX], // column headings for procflgs
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#endif
|
2011-04-15 04:54:29 +05:30
|
|
|
|
*captab [CAPTABMAX]; // captab needed by show_special()
|
top: highlight all regular search string(s) when found
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>
2012-12-08 11:30:00 +05:30
|
|
|
|
char *findstr; // window's current/active search string
|
|
|
|
|
int findlen; // above's strlen, without call overhead
|
2011-08-30 17:35:45 +05:30
|
|
|
|
proc_t **ppt; // this window's proc_t ptr array
|
2011-03-31 16:45:12 +05:30
|
|
|
|
struct WIN_t *next, // next window in window stack
|
|
|
|
|
*prev; // prior window in window stack
|
|
|
|
|
} WIN_t;
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
// Used to test/manipulate the window flags
|
|
|
|
|
#define CHKw(q,f) (int)((q)->rc.winflags & (f))
|
|
|
|
|
#define TOGw(q,f) (q)->rc.winflags ^= (f)
|
|
|
|
|
#define SETw(q,f) (q)->rc.winflags |= (f)
|
|
|
|
|
#define OFFw(q,f) (q)->rc.winflags &= ~(f)
|
|
|
|
|
#define ALTCHKw (Rc.mode_altscr ? 1 : win_warn(Warn_ALT))
|
|
|
|
|
#define VIZISw(q) (!Rc.mode_altscr || CHKw(q,Show_TASKON))
|
|
|
|
|
#define VIZCHKw(q) (VIZISw(q)) ? 1 : win_warn(Warn_VIZ)
|
|
|
|
|
#define VIZTOGw(q,f) (VIZISw(q)) ? TOGw(q,(f)) : win_warn(Warn_VIZ)
|
2002-02-02 04:17:29 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
// Used to test/manipulte fieldscur values
|
top: honor the restrictive, crufty old top rcfile
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>
2012-03-01 11:29:59 +05:30
|
|
|
|
#define FLDon(c) ((c) |= 0x80)
|
2011-03-31 16:45:12 +05:30
|
|
|
|
#define FLDget(q,i) ((FLG_t)((q)->rc.fieldscur[i] & 0x7f) - FLD_OFFSET)
|
|
|
|
|
#define FLDtog(q,i) ((q)->rc.fieldscur[i] ^= 0x80)
|
|
|
|
|
#define FLDviz(q,i) ((q)->rc.fieldscur[i] & 0x80)
|
2011-08-30 17:35:45 +05:30
|
|
|
|
#define ENUchk(w,E) (NULL != strchr((w)->rc.fieldscur, (E + FLD_OFFSET) | 0x80))
|
|
|
|
|
#define ENUset(w,E) do { char *t; \
|
|
|
|
|
if ((t = strchr((w)->rc.fieldscur, E + FLD_OFFSET))) \
|
|
|
|
|
*t = (E + FLD_OFFSET) | 0x80; \
|
|
|
|
|
/* else fieldscur char already has high bit on! */ \
|
|
|
|
|
} while (0)
|
|
|
|
|
#define ENUviz(w,E) (NULL != memchr((w)->procflgs, E, (w)->maxpflgs))
|
2011-09-12 17:48:23 +05:30
|
|
|
|
#define ENUpos(w,E) ((int)((FLG_t*)memchr((w)->pflgsall, E, (w)->totpflgs) - (w)->pflgsall))
|
2011-08-30 17:35:45 +05:30
|
|
|
|
|
2012-06-30 10:30:00 +05:30
|
|
|
|
// Support for variable width columns (and potentially scrolling too)
|
2012-09-19 11:31:01 +05:30
|
|
|
|
#define VARcol(E) (-1 == Fieldstab[E].width)
|
2012-06-30 10:30:00 +05:30
|
|
|
|
#ifndef SCROLLVAR_NO
|
|
|
|
|
#ifdef USE_X_COLHDR
|
|
|
|
|
#define VARright(w) (1 == w->maxpflgs && VARcol(w->procflgs[0]))
|
|
|
|
|
#else
|
|
|
|
|
#define VARright(w) ((1 == w->maxpflgs && VARcol(w->procflgs[0])) || \
|
|
|
|
|
(3 == w->maxpflgs && X_XON == w->procflgs[0] && VARcol(w->procflgs[1])))
|
|
|
|
|
#endif
|
|
|
|
|
#define VARleft(w) (w->varcolbeg && VARright(w))
|
|
|
|
|
#define SCROLLAMT 8
|
|
|
|
|
#endif
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Special Section: end ------------------------------------------ */
|
|
|
|
|
/* /////////////////////////////////////////////////////////////// */
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*###### Some Miscellaneous Macro definitions ##########################*/
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Yield table size as 'int' */
|
|
|
|
|
#define MAXTBL(t) (int)(sizeof(t) / sizeof(t[0]))
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* A null-terminating strncpy, assuming strlcpy is not available.
|
|
|
|
|
( and assuming callers don't need the string length returned ) */
|
|
|
|
|
#define STRLCPY(dst,src) { strncpy(dst, src, sizeof(dst)); dst[sizeof(dst) - 1] = '\0'; }
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Used to clear all or part of our Pseudo_screen */
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#define PSU_CLREOS(y) memset(&Pseudo_screen[ROWMAXSIZ*y], '\0', Pseudo_size-(ROWMAXSIZ*y))
|
2002-12-05 04:18:30 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Used as return arguments in *some* of the sort callbacks */
|
|
|
|
|
#define SORT_lt ( Frame_srtflg > 0 ? 1 : -1 )
|
|
|
|
|
#define SORT_gt ( Frame_srtflg > 0 ? -1 : 1 )
|
|
|
|
|
#define SORT_eq 0
|
|
|
|
|
|
|
|
|
|
/* Used to create *most* of the sort callback functions
|
|
|
|
|
note: some of the callbacks are NOT your father's callbacks, they're
|
|
|
|
|
highly optimized to save them ol' precious cycles! */
|
|
|
|
|
#define SCB_NAME(f) sort_P_ ## f
|
|
|
|
|
#define SCB_NUM1(f,n) \
|
|
|
|
|
static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
|
|
|
|
|
if ( (*P)->n < (*Q)->n ) return SORT_lt; \
|
|
|
|
|
if ( (*P)->n > (*Q)->n ) return SORT_gt; \
|
|
|
|
|
return SORT_eq; }
|
|
|
|
|
#define SCB_NUMx(f,n) \
|
|
|
|
|
static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
|
|
|
|
|
return Frame_srtflg * ( (*Q)->n - (*P)->n ); }
|
|
|
|
|
#define SCB_STRS(f,s) \
|
|
|
|
|
static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
|
2011-11-22 01:13:17 +05:30
|
|
|
|
if (!(*P)->s || !(*Q)->s) return SORT_eq; \
|
2012-04-11 14:41:12 +05:30
|
|
|
|
return Frame_srtflg * STRCMP((*Q)->s, (*P)->s); }
|
2011-05-18 14:03:44 +05:30
|
|
|
|
#define SCB_STRV(f,b,v,s) \
|
2011-05-05 15:37:25 +05:30
|
|
|
|
static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
|
2011-05-18 14:03:44 +05:30
|
|
|
|
if (b) { \
|
|
|
|
|
if (!(*P)->v || !(*Q)->v) return SORT_eq; \
|
2012-04-11 14:41:12 +05:30
|
|
|
|
return Frame_srtflg * STRCMP((*Q)->v[0], (*P)->v[0]); } \
|
|
|
|
|
return Frame_srtflg * STRCMP((*Q)->s, (*P)->s); }
|
2011-08-01 16:58:46 +05:30
|
|
|
|
#define SCB_STRX(f,s) \
|
|
|
|
|
int strverscmp(const char *s1, const char *s2); \
|
|
|
|
|
static int SCB_NAME(f) (const proc_t **P, const proc_t **Q) { \
|
2011-11-22 01:13:17 +05:30
|
|
|
|
if (!(*P)->s || !(*Q)->s) return SORT_eq; \
|
2011-08-01 16:58:46 +05:30
|
|
|
|
return Frame_srtflg * strverscmp((*Q)->s, (*P)->s); }
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
/*
|
top: highlight all regular search string(s) when found
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>
2012-12-08 11:30:00 +05:30
|
|
|
|
* The following three macros are used to 'inline' those portions of the
|
|
|
|
|
* display process involved in formatting, while protecting against any
|
2011-03-31 16:45:12 +05:30
|
|
|
|
* potential embedded 'millesecond delay' escape sequences.
|
|
|
|
|
*/
|
|
|
|
|
/** PUTT - Put to Tty (used in many places)
|
|
|
|
|
. for temporary, possibly interactive, 'replacement' output
|
|
|
|
|
. may contain ANY valid terminfo escape sequences
|
|
|
|
|
. need NOT represent an entire screen row */
|
|
|
|
|
#define PUTT(fmt,arg...) do { \
|
2011-04-14 02:38:14 +05:30
|
|
|
|
char _str[ROWMAXSIZ]; \
|
2011-03-31 16:45:12 +05:30
|
|
|
|
snprintf(_str, sizeof(_str), fmt, ## arg); \
|
|
|
|
|
putp(_str); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
|
|
/** PUFF - Put for Frame (used in only 3 places)
|
|
|
|
|
. for more permanent frame-oriented 'update' output
|
|
|
|
|
. may NOT contain cursor motion terminfo escapes
|
|
|
|
|
. assumed to represent a complete screen ROW
|
|
|
|
|
. subject to optimization, thus MAY be discarded */
|
|
|
|
|
#define PUFF(fmt,arg...) do { \
|
2011-06-01 17:28:06 +05:30
|
|
|
|
char _str[ROWMAXSIZ], *_eol; \
|
|
|
|
|
_eol = _str + snprintf(_str, sizeof(_str), fmt, ## arg); \
|
|
|
|
|
if (Batch) { \
|
|
|
|
|
while (*(--_eol) == ' '); *(++_eol) = '\0'; putp(_str); } \
|
2011-03-31 16:45:12 +05:30
|
|
|
|
else { \
|
2011-04-14 02:38:14 +05:30
|
|
|
|
char *_ptr = &Pseudo_screen[Pseudo_row * ROWMAXSIZ]; \
|
2011-03-31 16:45:12 +05:30
|
|
|
|
if (Pseudo_row + 1 < Screen_rows) ++Pseudo_row; \
|
|
|
|
|
if (!strcmp(_ptr, _str)) putp("\n"); \
|
|
|
|
|
else { \
|
|
|
|
|
strcpy(_ptr, _str); \
|
|
|
|
|
putp(_ptr); } } \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
top: highlight all regular search string(s) when found
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>
2012-12-08 11:30:00 +05:30
|
|
|
|
/** POOF - Pulled Out of Frame (used in only 1 place)
|
|
|
|
|
. for output that is/was sent directly to the terminal
|
|
|
|
|
but would otherwise have been counted as a Pseudo_row */
|
|
|
|
|
#define POOF(str,cap) do { \
|
|
|
|
|
putp(str); putp(cap); \
|
2012-12-30 11:30:00 +05:30
|
|
|
|
Pseudo_screen[Pseudo_row * ROWMAXSIZ] = '\0'; \
|
top: highlight all regular search string(s) when found
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>
2012-12-08 11:30:00 +05:30
|
|
|
|
if (Pseudo_row + 1 < Screen_rows) ++Pseudo_row; \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Orderly end, with any sort of message - see fmtmk */
|
|
|
|
|
#define debug_END(s) { \
|
2013-01-11 11:30:00 +05:30
|
|
|
|
void error_exit (const char *); \
|
2011-03-31 16:45:12 +05:30
|
|
|
|
fputs(Cap_clr_scr, stdout); \
|
|
|
|
|
error_exit(s); \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* A poor man's breakpoint, if he's too lazy to learn gdb */
|
|
|
|
|
#define its_YOUR_fault { *((char *)0) = '!'; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*###### Display Support *Data* ########################################*/
|
2011-10-12 00:32:59 +05:30
|
|
|
|
/*###### Some Display Support *Data* ###################################*/
|
|
|
|
|
/* ( see module top_nls.c for the nls translatable data ) */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
/* Configuration files support */
|
|
|
|
|
#define SYS_RCFILESPEC "/etc/toprc"
|
|
|
|
|
#define RCF_EYECATCHER "Config File (Linux processes with windows)\n"
|
2012-09-20 11:31:01 +05:30
|
|
|
|
#define RCF_VERSION_ID 'g'
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
/* The default fields displayed and their order, if nothing is
|
|
|
|
|
specified by the loser, oops user.
|
|
|
|
|
note: any *contiguous* ascii sequence can serve as fieldscur
|
|
|
|
|
characters as long as the initial value is coordinated
|
|
|
|
|
with that specified for FLD_OFFSET
|
|
|
|
|
( we're providing for up to 55 fields initially, )
|
|
|
|
|
( with values chosen to avoid the need to escape ) */
|
|
|
|
|
#define FLD_OFFSET '%'
|
|
|
|
|
// seq_fields "%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ["
|
|
|
|
|
#define DEF_FIELDS "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>&')*+,-./012568<>?ABCFGHIJKLMNOPQRSTUVWXYZ["
|
|
|
|
|
/* Pre-configured windows/field groups */
|
|
|
|
|
#define JOB_FIELDS "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>()*+,-./012568>?@ABCFGHIJKLMNOPQRSTUVWXYZ["
|
|
|
|
|
#define MEM_FIELDS "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3><EFBFBD>&'()*+,-./0125689BFGHIJKLMNOPQRSTUVWXYZ["
|
|
|
|
|
#define USR_FIELDS "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)+,-./1234568;<=>?@ABCFGHIJKLMNOPQRSTUVWXYZ["
|
2012-03-03 00:04:56 +05:30
|
|
|
|
#ifdef OOMEM_ENABLE
|
|
|
|
|
// the suse old top fields ( 'a'-'z' + '{|' ) in positions 0-27
|
|
|
|
|
// ( the extra chars above represent the 'off' state )
|
|
|
|
|
#define CVT_FIELDS "%&*'(-0346789:;<=>?@ACDEFGML)+,./125BHIJKNOPQRSTUVWXYZ["
|
|
|
|
|
#define CVT_FLDMAX 28
|
|
|
|
|
#else
|
|
|
|
|
// other old top fields ( 'a'-'z' ) in positions 0-25
|
|
|
|
|
#define CVT_FIELDS "%&*'(-0346789:;<=>?@ACDEFG)+,./125BHIJKLMNOPQRSTUVWXYZ["
|
|
|
|
|
#define CVT_FLDMAX 26
|
|
|
|
|
#endif
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|
|
|
|
|
/* The default values for the local config file */
|
2002-12-05 04:18:30 +05:30
|
|
|
|
#define DEF_RCFILE { \
|
top: honor the restrictive, crufty old top rcfile
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>
2012-03-01 11:29:59 +05:30
|
|
|
|
RCF_VERSION_ID, 0, 1, DEF_DELAY, 0, { \
|
2002-12-05 04:18:30 +05:30
|
|
|
|
{ P_CPU, DEF_WINFLGS, 0, \
|
|
|
|
|
COLOR_RED, COLOR_RED, COLOR_YELLOW, COLOR_RED, \
|
|
|
|
|
"Def", DEF_FIELDS }, \
|
|
|
|
|
{ P_PID, DEF_WINFLGS, 0, \
|
|
|
|
|
COLOR_CYAN, COLOR_CYAN, COLOR_WHITE, COLOR_CYAN, \
|
|
|
|
|
"Job", JOB_FIELDS }, \
|
|
|
|
|
{ P_MEM, DEF_WINFLGS, 0, \
|
|
|
|
|
COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLUE, COLOR_MAGENTA, \
|
|
|
|
|
"Mem", MEM_FIELDS }, \
|
2011-03-31 16:45:12 +05:30
|
|
|
|
{ P_UEN, DEF_WINFLGS, 0, \
|
2002-12-05 04:18:30 +05:30
|
|
|
|
COLOR_YELLOW, COLOR_YELLOW, COLOR_GREEN, COLOR_YELLOW, \
|
|
|
|
|
"Usr", USR_FIELDS } \
|
2013-01-02 11:30:00 +05:30
|
|
|
|
}, 0, SK_Kb, SK_Kb, 0 }
|
2002-12-05 04:18:30 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/* Summary Lines specially formatted string(s) --
|
|
|
|
|
see 'show_special' for syntax details + other cautions. */
|
2002-06-19 05:15:30 +05:30
|
|
|
|
#define LOADAV_line "%s -%s\n"
|
2011-10-28 21:00:40 +05:30
|
|
|
|
#define LOADAV_line_alt "%s~6 -%s\n"
|
2002-06-19 05:15:30 +05:30
|
|
|
|
|
2002-11-29 04:39:48 +05:30
|
|
|
|
|
2002-11-29 21:31:04 +05:30
|
|
|
|
/*###### For Piece of mind #############################################*/
|
2002-11-29 04:39:48 +05:30
|
|
|
|
|
|
|
|
|
/* just sanity check(s)... */
|
2011-04-14 02:38:14 +05:30
|
|
|
|
#if defined(ATEOJ_RPTHSH) && defined(OFF_HST_HASH)
|
|
|
|
|
# error 'ATEOJ_RPTHSH' conflicts with 'OFF_HST_HASH'
|
2002-11-29 04:39:48 +05:30
|
|
|
|
#endif
|
2011-05-26 15:03:32 +05:30
|
|
|
|
#if (LRGBUFSIZ < SCREENMAX)
|
|
|
|
|
# error 'LRGBUFSIZ' must NOT be less than 'SCREENMAX'
|
|
|
|
|
#endif
|
2011-04-14 02:38:14 +05:30
|
|
|
|
|
2002-11-29 04:39:48 +05:30
|
|
|
|
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*###### Some Prototypes (ha!) #########################################*/
|
|
|
|
|
|
2012-02-11 13:32:02 +05:30
|
|
|
|
/* These 'prototypes' are here exclusively for documentation purposes. */
|
|
|
|
|
/* ( see the find_string function for the one true required protoype ) */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*------ Sort callbacks ------------------------------------------------*/
|
|
|
|
|
/* for each possible field, in the form of: */
|
|
|
|
|
/*atic int sort_P_XXX (const proc_t **P, const proc_t **Q); */
|
|
|
|
|
/*------ Tiny useful routine(s) ----------------------------------------*/
|
|
|
|
|
//atic const char *fmtmk (const char *fmts, ...);
|
|
|
|
|
//atic inline char *scat (char *dst, const char *src);
|
|
|
|
|
//atic const char *tg2 (int x, int y);
|
|
|
|
|
/*------ Exit/Interrput routines ---------------------------------------*/
|
2012-12-12 11:30:00 +05:30
|
|
|
|
//atic void at_eoj (void);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void bye_bye (const char *str);
|
|
|
|
|
//atic void error_exit (const char *str);
|
2011-11-22 01:13:17 +05:30
|
|
|
|
//atic void library_err (const char *fmts, ...);
|
2011-09-12 17:48:23 +05:30
|
|
|
|
//atic void sig_abexit (int sig);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void sig_endpgm (int dont_care_sig);
|
|
|
|
|
//atic void sig_paused (int dont_care_sig);
|
|
|
|
|
//atic void sig_resize (int dont_care_sig);
|
|
|
|
|
/*------ Misc Color/Display support ------------------------------------*/
|
|
|
|
|
//atic void capsmk (WIN_t *q);
|
|
|
|
|
//atic void show_msg (const char *str);
|
|
|
|
|
//atic int show_pmt (const char *str);
|
|
|
|
|
//atic inline void show_scroll (void);
|
|
|
|
|
//atic void show_special (int interact, const char *glob);
|
2012-06-30 10:30:22 +05:30
|
|
|
|
//atic void updt_scroll_msg (void);
|
top: add a flexible 'Inspect' capability
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>
2012-11-25 10:30:05 +05:30
|
|
|
|
/*------ Low Level Memory/Keyboard/File I/O support --------------------*/
|
2011-12-20 19:53:37 +05:30
|
|
|
|
//atic void *alloc_c (size_t num);
|
|
|
|
|
//atic void *alloc_r (void *ptr, size_t num);
|
2013-01-16 11:30:00 +05:30
|
|
|
|
//atic inline int ioa (struct timespec *ts);
|
2013-01-16 11:30:00 +05:30
|
|
|
|
//atic int ioch (int ech, char *buf, unsigned cnt);
|
|
|
|
|
//atic int iokey (int init);
|
|
|
|
|
//atic char *ioline (const char *prompt);
|
2012-11-28 11:30:00 +05:30
|
|
|
|
//atic int readfile (FILE *fp, char **baddr, size_t *bsize, size_t *bread);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*------ Small Utility routines ----------------------------------------*/
|
|
|
|
|
//atic float get_float (const char *prompt);
|
|
|
|
|
//atic int get_int (const char *prompt);
|
2012-09-19 11:31:01 +05:30
|
|
|
|
//atic inline const char *hex_make (KLONG num, int noz);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic const char *user_certify (WIN_t *q, const char *str, char typ);
|
|
|
|
|
//atic inline int user_matched (WIN_t *q, const proc_t *p);
|
2012-09-19 11:31:01 +05:30
|
|
|
|
/*------ Basic Formatting support --------------------------------------*/
|
|
|
|
|
//atic inline const char *justify_pad (const char *str, int width, int justr);
|
2012-10-06 01:45:15 +05:30
|
|
|
|
//atic inline const char *make_chr (const char ch, int width, int justr);
|
|
|
|
|
//atic inline const char *make_num (long num, int width, int justr, int col);
|
|
|
|
|
//atic inline const char *make_str (const char *str, int width, int justr, int col);
|
top: provide the means to adjust scaled process memory
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>
2012-12-14 11:30:00 +05:30
|
|
|
|
//atic const char *scale_mem (int target, unsigned long num, int width, int justr);
|
|
|
|
|
//atic const char *scale_num (unsigned long num, int width, int justr);
|
|
|
|
|
//atic const char *scale_pcnt (float num, int width, int justr);
|
2012-09-19 11:31:01 +05:30
|
|
|
|
//atic const char *scale_tics (TIC_t tics, int width, int justr);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*------ Fields Management support -------------------------------------*/
|
|
|
|
|
/*atic FLD_t Fieldstab[] = { ... } */
|
|
|
|
|
//atic void adj_geometry (void);
|
2012-02-09 09:52:22 +05:30
|
|
|
|
//atic void build_headers (void);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void calibrate_fields (void);
|
2011-05-26 15:03:32 +05:30
|
|
|
|
//atic void display_fields (int focus, int extend);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void fields_utility (void);
|
2012-10-03 23:43:13 +05:30
|
|
|
|
//atic inline void widths_resize (void);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void zap_fieldstab (void);
|
|
|
|
|
/*------ Library Interface ---------------------------------------------*/
|
|
|
|
|
//atic CPU_t *cpus_refresh (CPU_t *cpus);
|
|
|
|
|
#ifdef OFF_HST_HASH
|
|
|
|
|
//atic inline HST_t *hstbsrch (HST_t *hst, int max, int pid);
|
|
|
|
|
#else
|
|
|
|
|
//atic inline HST_t *hstget (int pid);
|
|
|
|
|
//atic inline void hstput (unsigned idx);
|
|
|
|
|
#endif
|
2012-02-07 22:41:11 +05:30
|
|
|
|
//atic void procs_hlp (proc_t *p);
|
2011-08-30 17:35:45 +05:30
|
|
|
|
//atic void procs_refresh (void);
|
2011-07-14 16:46:02 +05:30
|
|
|
|
//atic void sysinfo_refresh (int forced);
|
top: add a flexible 'Inspect' capability
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>
2012-11-25 10:30:05 +05:30
|
|
|
|
/*------ Inspect Other Output ------------------------------------------*/
|
|
|
|
|
//atic void insp_cnt_nl (void);
|
|
|
|
|
#ifndef INSP_OFFDEMO
|
|
|
|
|
//atic void insp_do_demo (char *fmts, int pid);
|
|
|
|
|
#endif
|
|
|
|
|
//atic void insp_do_file (char *fmts, int pid);
|
|
|
|
|
//atic void insp_do_pipe (char *fmts, int pid);
|
2012-12-03 11:30:00 +05:30
|
|
|
|
//atic inline int insp_find_ofs (int col, int row);
|
|
|
|
|
//atic void insp_find_str (int ch, int *col, int *row);
|
|
|
|
|
//atic inline void insp_make_row (int col, int row);
|
|
|
|
|
//atic void insp_show_pgs (int col, int row, int max);
|
2012-12-04 11:30:00 +05:30
|
|
|
|
//atic int insp_view_choice (proc_t *obj);
|
top: add a flexible 'Inspect' capability
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>
2012-11-25 10:30:05 +05:30
|
|
|
|
//atic void inspection_utility (int pid);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*------ Startup routines ----------------------------------------------*/
|
|
|
|
|
//atic void before (char *me);
|
top: honor the restrictive, crufty old top rcfile
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>
2012-03-01 11:29:59 +05:30
|
|
|
|
//atic int config_cvt (WIN_t *q);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void configs_read (void);
|
|
|
|
|
//atic void parse_args (char **args);
|
|
|
|
|
//atic void whack_terminal (void);
|
|
|
|
|
/*------ Windows/Field Groups support ----------------------------------*/
|
|
|
|
|
//atic void win_names (WIN_t *q, const char *name);
|
2013-01-11 11:30:00 +05:30
|
|
|
|
//atic WIN_t *win_select (int ch);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic int win_warn (int what);
|
2012-02-07 22:41:11 +05:30
|
|
|
|
//atic void wins_clrhlp (WIN_t *q, int save);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void wins_colors (void);
|
|
|
|
|
//atic void wins_reflag (int what, int flg);
|
|
|
|
|
//atic void wins_stage_1 (void);
|
|
|
|
|
//atic void wins_stage_2 (void);
|
|
|
|
|
/*------ Interactive Input support (do_key helpers) --------------------*/
|
|
|
|
|
//atic void file_writerc (void);
|
top: highlight all regular search string(s) when found
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>
2012-12-08 11:30:00 +05:30
|
|
|
|
//atic inline int find_ofs (const WIN_t *q, const char *buf);
|
2011-12-17 01:34:38 +05:30
|
|
|
|
//atic void find_string (int ch);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void help_view (void);
|
|
|
|
|
//atic void keys_global (int ch);
|
|
|
|
|
//atic void keys_summary (int ch);
|
|
|
|
|
//atic void keys_task (int ch);
|
|
|
|
|
//atic void keys_window (int ch);
|
|
|
|
|
//atic void keys_xtra (int ch);
|
2011-08-30 17:35:45 +05:30
|
|
|
|
/*------ Forest View support -------------------------------------------*/
|
2012-08-26 10:29:59 +05:30
|
|
|
|
//atic void forest_adds (const int self, const int level);
|
|
|
|
|
//atic int forest_based (const proc_t **x, const proc_t **y);
|
2011-08-30 17:35:45 +05:30
|
|
|
|
//atic void forest_create (WIN_t *q);
|
|
|
|
|
//atic inline const char *forest_display (const WIN_t *q, const proc_t *p);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*------ Main Screen routines ------------------------------------------*/
|
|
|
|
|
//atic void do_key (int ch);
|
2012-02-07 22:41:11 +05:30
|
|
|
|
//atic void summary_hlp (CPU_t *cpu, const char *pfx);
|
2011-08-30 17:35:45 +05:30
|
|
|
|
//atic void summary_show (void);
|
2012-09-19 11:31:01 +05:30
|
|
|
|
//atic const char *task_show (const WIN_t *q, const proc_t *p);
|
2011-08-30 17:35:45 +05:30
|
|
|
|
//atic int window_show (WIN_t *q, int wmax);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
/*------ Entry point plus two ------------------------------------------*/
|
2012-02-07 22:41:11 +05:30
|
|
|
|
//atic void frame_hlp (int wix, int max);
|
2011-03-31 16:45:12 +05:30
|
|
|
|
//atic void frame_make (void);
|
|
|
|
|
// int main (int dont_care_argc, char **argv);
|
2002-05-30 09:14:46 +05:30
|
|
|
|
|
|
|
|
|
#endif /* _Itop */
|
2011-03-31 16:45:12 +05:30
|
|
|
|
|