miscellaneous top program/man document cleanup

Program changes
  . corrected eolcap handling if EQUCOLHDRYES defined
  . added missing terminator for OOMEM_ENABLE comment
  . tightened logic in display_fields
  . eliminated some warnings via type or cast
  . updated miscellaneous source comments
 Man Document changes
  . corrected/expanded CGROUPS narrative
  . standardized/normalized PPID narrative

Signed-off-by: Jan Görig <jgorig@redhat.com>
This commit is contained in:
Jim Warner 2011-06-23 15:45:09 +02:00 committed by Jan Görig
parent 16f8bc685f
commit 29b8775c39
3 changed files with 21 additions and 14 deletions

11
top.1
View File

@ -422,8 +422,11 @@ For additional information on sort provisions
\*(Xt 4c. TASK AREA Commands, SORTING.
.TP 4
1.\fB CGROUPS \*(Em Code Size (kb) \fR
Control groups provide for allocating resources (cpu, memory, network
1.\fB CGROUPS \*(Em Control Groups \fR
The names of the control group(s) to which a process belongs,
or '-' if not applicable for that process.
Control Groups provide for allocating resources (cpu, memory, network
bandwidth, etc.) among installation-defined groups of processes.
They enable fine-grained control over allocating, denying, prioritizing,
managing and monitoring those resources.
@ -558,8 +561,8 @@ a session ID for the session leader (\*(Xa SID);
and a TTY process group ID for the process group leader (\*(Xa TPGID).
.TP 4
18.\fB PPID \*(Em Parent Process pid \fR
The process ID of a task's parent.
18.\fB PPID \*(Em Parent Process Id \fR
The process ID (pid) of a task's parent.
.TP 4
19.\fB PR \*(Em Priority \fR

22
top.c
View File

@ -447,7 +447,7 @@ static void bye_bye (const char *str) {
"\t %5d total entries occupied\n", cross_foot);
if (maxdepth_sav) {
fprintf(stderr, "PIDs at max depth: ");
fprintf(stderr, "\nPIDs at max depth: ");
for (i = 0; i < HHASH_SIZ; i++)
if (depths[i] == maxdepth_sav) {
j = PHash_new[i];
@ -1231,7 +1231,7 @@ static FLD_t Fieldstab[] = {
#else
{ "Flags ", "%08lx ", -1, -1, SF(FLG), L_stat, "Task Flags <sched.h>" },
#endif
// next entry's like P_CMD, and '.head' must be the same length -- they share varcolsz
// next entry's like P_CMD/P_WCH, and '.head' must be same length -- they share varcolsz
{ "CGROUPS ", NULL, -1, -1, SF(CGR), L_CGROUP, "Control Groups" }
#ifdef OOMEM_ENABLE
#define L_oom PROC_FILLOOM
@ -1324,7 +1324,7 @@ static void adj_geometry (void) {
* via adj_geometry(), for each visible window:
* 1) Set the number of fields/columns to display
* 2) Create the field columns heading
* 3) Set maximum cmdline length, if command lines are in use
* 3) Set maximum width for any variable columns, if in use
* In the process, the required PROC_FILLxxx flags will be rebuilt! */
static void calibrate_fields (void) {
sigset_t newss, oldss;
@ -1439,10 +1439,10 @@ static void calibrate_fields (void) {
#ifdef EQUCOLHDRYES
// prepare to even out column header lengths...
if (hdrmax + w->hdrcaplen < (x = strlen(w->columnhdr))) hdrmax = x - w->hdrcaplen;
if (Screen_cols > x - w->hdrcaplen) w->eolcap = Caps_endline;
else w->eolcap = Caps_off;
// must sacrifice last header positon to avoid task row abberations
w->eolcap = Caps_endline;
#else
if (Screen_cols > strlen(w->columnhdr)) w->eolcap = Caps_endline;
if (Screen_cols > (int)strlen(w->columnhdr)) w->eolcap = Caps_endline;
else w->eolcap = Caps_off;
#endif
// we must also accommodate an out of view sort field...
@ -1535,7 +1535,7 @@ static void display_fields (int focus, int extend) {
if (rmax < i + (P_MAXPFLGS / mxCOL)) error_exit("++rows");
i = P_MAXPFLGS / rmax;
if (P_MAXPFLGS % rmax) ++i;
if (i > 1) { cmax = Screen_cols / i; xadd = 1; }
if (i > 1) { cmax /= i; xadd = 1; }
if (cmax > xTOTL) cmax = xTOTL;
smax = cmax - xPRFX;
if (smax < 0) error_exit("++cols");
@ -1806,7 +1806,9 @@ static inline void hstput (unsigned idx) {
* 3) maintaining the HST_t's and priming the proc_t pcpu field
* 4) establishing the total number tasks for this frame */
static void prochlp (proc_t *this) {
#ifdef OFF_HST_HASH
static unsigned maxt_sav = 0; // prior frame's max tasks
#endif
TIC_t tics;
HST_t *h;
@ -1825,7 +1827,9 @@ static void prochlp (proc_t *this) {
// if in Solaris mode, adjust our scaling for all cpus
Frame_etscale = 100.0f / ((float)Hertz * (float)et * (Rc.mode_irixps ? 1 : Cpu_tot));
#ifdef OFF_HST_HASH
maxt_sav = Frame_maxtask;
#endif
Frame_maxtask = Frame_running = Frame_sleepin = Frame_stopped = Frame_zombied = 0;
// prep for saving this frame's HST_t's (and reuse mem each time around)
@ -2249,10 +2253,10 @@ static void parse_args (char **args) {
break;
}
case 'w':
{ char *pn = NULL;
{ const char *pn = NULL;
int ai = 0, ci = 0;
Width_mode = -1;
if (cp[1]) pn = (char*)&cp[1];
if (cp[1]) pn = &cp[1];
else if (*args) { pn = *args; ai = 1; }
if (pn && !(ci = strspn(pn, "0123456789"))) { ai = 0; pn = NULL; }
if (pn && (1 != sscanf(pn, "%d", &Width_mode)

2
top.h
View File

@ -27,7 +27,7 @@
//#define EQUCOLHDRYES /* yes, do equalize column header lengths */
//#define OFF_HST_HASH /* use BOTH qsort+bsrch vs. hashing scheme */
//#define OFF_STDIOLBF /* disable our own stdout _IOFBF override */
//#define OOMEM_ENABLE /* enable the SuSE out-of-memory additions *
//#define OOMEM_ENABLE /* enable the SuSE out-of-memory additions */
//#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 */