Commit Graph

166 Commits

Author SHA1 Message Date
Jim Warner
d6e6a9aa38 top: add a search capability 2011-12-20 22:15:31 +11:00
Jim Warner
80e2f59e05 top: provide own SIGRTMAX, if not already defined
Protect against a compile failure, as on HURD.

Reference:
  https://buildd.debian.org/status/package.php?p=procps&suite=sid
  top.c:2102:13: error: 'SIGRTMAX' undeclared (first use in this function)
2011-12-11 22:28:11 +11:00
Jim Warner
1e4447d171 top: circumvent a false positive smatch error
The smatch error --------------
top.c +1414 calibrate_fields(78) error: buffer overflow 'Fieldstab' 39 <= 39

  The code -----------------------
if (P_MAXPFLGS < f) { w->endpflg = i; continue; }

  The background -----------------
The enum P_MAXPFLGS is strictly a fencepost and can *never* appear in
the arrays pflgsall or procflgs.  Thus it (39th element) cannot be used
in referencing Fieldstab.

However, two enums of higher value (X_XON=40 and X_XOF=41) *can* appear
in those arrays.  But the test against the fencepost ensures that those
two enums are *never* used in referencing Fieldstab.

When the analyzer sees the conditional using '<' and not '<='
it reports a false positive.

The source was changed to accommodate the tool's deficiency
2011-12-11 22:28:03 +11:00
Jim Warner
cd608f462e top: forest view segmentation fault, the final solution
With forest view mode under procps-ng-3.3.0, top would catch
a SEGV and exit.  The problem was thought to be related to
some linux version 3 anamoly.

In procps-ng-3.3.1, top was protected from abnormal exit and
would display the offending processes with the special orphan
notation '?', instead of the usual artwork.

As it turns out, the problem wasn't with linux and could
surface under a 2.6.xx kernel,  The cause was an occasional
abnormal ordering of tid/tgid/ppid which went unresolved
due to a progressive proc table scan in the recursive
function forest_add().

By default the proc table scan now restarts at the beginning.
However, a #define TREE_ONEPASS is provided should one wish
to restore the 3.3.1 behavior with its reduced overhead.
2011-12-11 22:27:56 +11:00
Jim Warner
242be5194c top: correct an obscure column highlighting buglet
An anomaly would surface whenever the sort column was
made non-display under fields management.

The scroll message would report incorrect x coordinates
and the 'x' toggle would produce an unintentional
horizontal scroll.

This patch forces column highlighting off whenever field
changes are made (as is done for horizontal scrolling).
It also inactivates the 'x' toggle whenever the sort
column is not visible.

This bug has yet to be reported.
2011-12-11 22:27:47 +11:00
Jim Warner
c8bbcec5db top: improve the most heavily used library interface
In the procs_refresh() function:
. the proctable scan was simplified
. memory allocation is now much more efficient
. window ppts will usually not now need xrealloc
2011-12-11 22:27:34 +11:00
Jim Warner
88087ec5a5 top: exploit enhanced library memory allocation provisions
Now that the library allows for customizing the response to
memory allocation errors, it is no longer necessary for top
to provide its own.

This library extension was necessary since top modifies the
termios structure and there would otherwise be no way to
restore the users tty.
2011-12-11 22:27:27 +11:00
Jim Warner
41ed28aa5d top: avoid potential forest view segmentation fault 2011-12-06 08:51:15 +11:00
Craig Small
497428d770 revert sentinel code for top 2011-12-06 08:51:06 +11:00
Jim Warner
be4d00ffe9 top: forest view contingency sentinal code added 2011-12-05 08:44:46 +11:00
Craig Small
e4836e08ee ncurses and configure again
Another fix to link properly to ncurses
Some minor top fixes
Added *~ to gitignore because these files crop up sometimes
2011-10-27 08:53:55 +11:00
Craig Small
ed01cfb8a9 Some tweaks for top
tweaked signal setup valgrind complaint as nls
some input error messages made more descriptive
eliminated audible escape a from all error messa
added include of proc readproc.h to top.h
optimization for show_special function
remove unnecessary variables clang analyze
2011-10-26 22:31:48 +11:00
Jim Warner
1055dff047 top: redesign show_special strs, in line with nls 2011-10-20 12:34:13 +02:00
Jim Warner
cea2e7ca5b rh analysis #2: top
http://www.freelists.org/post/procps/Scan-results,5
2011-10-19 09:33:43 +02:00
Craig Small
f7fb8bddf4 miscellaneous top and library cleanup
top changes
 . refined column header width calculations
 . added error messages for:
     invalid signal ('k')
     invalad max tasks ('n')
 . corrected narrative for summary_show

library changes
 . corrected some comments (only)
2011-09-25 00:27:37 +10:00
Craig Small
e4c45d6984 added ps etimes, miscellaneous top enhancements
ps program
 . etimes added for ELAPSED expressed in seconds
 . time_t used in place of former unsigned long

top program
 . corrected scroll message bug when 'x' toggle on
 . fixed forest view potential missing libflags bug
 . improved 'k' default signal invocation logic
 . enhanced logic for %CPU maximums displayed
 . made signal handling more robust and efficient
2011-09-12 22:18:23 +10:00
Craig Small
73ade5e2cb top now has a forest view mode 2011-08-30 22:05:45 +10:00
Craig Small
0e6ac0db3e added tgid support plus miscellaneous cleanup
ps
   . added tgid support
   . made process/task naming consistent
 top
   . added tgid support
   . standardized pid related width logic
 documents
   . added tgid to ps & top man documents
 library
   . fixed OOMEM_ENABLE readtask bug
   . corrected header typo for tgid
2011-08-17 21:01:35 +10:00
Craig Small
bb4f08ba29 refined library i/f and improved performance
Library changes
   readproc
    . added readeither to more efficiently
      fill both process and thread proc_t
    . added readproctab3, uses readeither
    . included task path support in:
        fill_cgroup_cvt, fill_cmdline_cvt,
        read_unvectored
    . QUICK_THREADS #define allows copying
      process info vs. repeatedly reading
    . simple_nexttid no longer values ppid
    . path var made non-static in readtask
    . documented 'proc_data_t' in .h file
    . tweaked some c comments & formatting
   library.map
    . added new readeither, readproctab3
 Program changes
   ps
    . exploits readproctab3 where possible
    . improved args/comm compliance
   top
    . exploits readeither
2011-08-11 07:42:14 +10:00
Craig Small
3ef4823f90 supgid/supgrp support, improved library interface
Library changes
   readproc
    . added support for supplementary groups
    . eliminated 2 potential mem leak sources
       . shortcut used for multi-threaded str
         vectors & ptrs was obsoleted
       . freeing of proc_t related dynamic
         memory now rests with the library
    . standardized/normalized many c comments
   sysinfo
    . corrected note regarding glibc & cpuinfo
   library.map
    . made the visible freeproc accessable
 Program changes
   pmap
    . initialized buffer for new readproc i/f
    . eliminated now obsolete free() call
   ps
    . added width aware supgrp support
    . initialized buffers for new readproc i/f
    . eliminated now obsolete free() calls
   top
    . added supgrp support as variable width
    . eliminated now obsolete free() calls
    . expoilted library freeproc function
    . corrected -h|v args text & spacing
    . updated some c comments
 Documentation changes
   ps.1
    . added supgid and supgrp
   top.1
    . added supgid and supgrp
    . addition of above required renumbering
      many fields in section 3a. DESCRIPTIONS
2011-08-01 21:28:46 +10:00
Craig Small
a26c3bfa39 top hotplug memory support
Another patch from Jim for top to support hot-pluggable memory. Not
fully tested on real hot-pluggable memory because neither of us have
it
2011-07-14 21:16:02 +10:00
Jim Warner
29b8775c39 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>
2011-06-23 15:45:09 +02:00
Jan Görig
034612c480 Fixed per-process swap information in top and related cleanup.
Thanks to KOSAKI Motohiro and Jim.

Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=532668
2011-06-02 12:15:14 +02:00
Jim Warner
c2dcbef482 added output width/height override support to top, + misc
This source patch addresses the following:
 Enhancements
  . added -w command line switch, with optional argument
   ( offers complete control over width and height, in  )
   ( combination with env variables COLUMNS= and LINES= )
  . updated man document to reflect the new capability
  . reengineered Fields Management to be more flexible
    thus no longer requiring a normal sized tty
 Buglets fixed
  . forced View_SCROLL off when in 'Batch' mode
  . for narrow xterm, fixed return val in show_pmt
  . for narrow xterm, fixed cursor pos in linein
  . added a window specific end-of-line termcap ptr
   ( so clr_eol does not overwrite last printable char )
 Cosmetic changes
  . eliminated TTYGETENVYES define, incorporated as -w
  . eliminated RESIZE_LIMIT define, no longer needed
  . eliminated FIELD_CURSOR define, no longer possible
  . eliminated extra text on Fields Management screen
  . fixed miscellaneous man document typos/formatting

Signed-off-by: Jan Görig <jgorig@redhat.com>
2011-05-26 11:33:32 +02:00
Jim Warner
7b0fc19e9d enhanced libproc cgroup/cmdline support, exploited by top
Library Changes
. added PROC_EDITCMDLCVT flag
. added an internal (static) fill_cmdline_cvt function:
  - reads and "escapes" /proc/#/cmdline
  - returns result as a single string in a single vector
  - callers are guaranteed a cmdline (no more NULL)
. added vectorize_this_str function, exploited by
  fill_cgroup_cvt, fill_cmdline_cvt
. generalized read_cmdline function as read_unvectored, now
  exploited by fill_cgroup_cvt, fill_cmdline_cvt, read_cmdline
  ( cgroup and cmdline no longer need be converted to string )
  ( vectors before being transformed to final representation )
. fixed bug regarding skipped group numbers (when enabled)
. escape_str made responsible for all single byte translation
  with distinction between control chars + other unprintable
. added escaped_copy function for already escaped strings
. reorganized parts of proc_t to restore formatting standards
  ( displacement changes shouldn't matter with new version # )
. former ZAP_SUSEONLY #define now OOMEM_ENABLE
. added to library.map: escaped_copy; read_cmdline

Top Program Changes
. exploited the new PROC_EDITCMDLCVT provision
. eliminated now obsolete #include "proc/escape.h"
. changed the P_WCH display format if no kernel symbol table
. fixed very old bug in lflgs for out-of-view sort fields
. former ZAP_SUSEONLY #define now OOMEM_ENABLE

Ps Program Changes
. exploited the new PROC_EDITCMDLCVT provision
. exploited the new escaped_copy function
. consolidated pr_args and pr_comm into pr_argcom

Signed-off-by: Jan Görig <jgorig@redhat.com>
2011-05-18 10:33:44 +02:00
Jim Warner
57031319d6 cgroup support migrated to libproc, plus miscellaneous re-formatting
This source patchset addresses the following:
Library Extension (readproc)
 . added PROC_EDITCGRPCVT flag
 . added an internal (static) fill_cgroup_cvt function:
   . reads AND parses /proc/#/cgroup
   . returns result as a single string in a single vector
   . thus no changes to proc_t structure or free memory logic
Program Enhancements (top)
 . removed parse_cgroup logic in favor of libproc
 . eliminated cgroup sort recurring overhead
 . converted WCHAN field to variable width
 . generalized variable width field logic in task_show
 . real-time notation under P col more distinctive as 'rt'
Program Cosmetic (top)
 . CGROUP now known as CGROUPS (plural)
 . moved jan's attribution from top.c to 'Notes' in top.h
 . numerous comments tweaked
Document Enhancements (top)
 . documented CGROUPS field (required renumbering all fields)
 . adapted narratives for the 3 current variable width fields
 . expanded real-time scheduling notes, 'RT' now shown as 'rt'

Signed-off-by: Jan Görig <jgorig@redhat.com>
2011-05-05 12:12:27 +02:00
Jan Görig
2a2fa20656 Fixed initialization and thread problems in top - changed by Jim 2011-04-18 16:06:54 +02:00
Craig Small
3ec6a27e8a cgroup support. rcfile errors default to fatal
This source patch addresses the following:
 Conceivable Buglets Avoided
  . added sanity checks for previous assumptions re: pid size, num cpus
  . changed response for rcfile errors to fatal, vs. silent default
 Enhancements
  . reorganized WIN_t struct for reduced padding and better readability
  . generalized code for multiple var-width cols (divorced from pflags)
  . absorbed jan gorig's cgroup patch, with attribution
 Cosmetic
  . reduced numerous #ifdef directives, especially in calibrate_fields
2011-04-15 09:24:29 +10:00
Craig Small
9bbaa0b3d2 several bug fixes, enhancements and formatting
The documentation portion of the patch addresses the following:
  README.top
    . corrected a minor typo
    . updated to reflect current patch level
  top.1
    . fixed potentially misinterpreted Me/ME strings
    . added '.Bd -literal' directives for indented fixed-width font
    . some comments changed from \# to .\" to avoid man2html problems

The source portion of the patch addresses the following:
  Buglets
    . header/task output length now consistent
    . fixed 2 obscure horizontal scrolling bugs
    . fixed potential bug regarding 'help' and 'current' window
    . messages and prompts are now also sensitive to terminal width
    . normalized buffer names/sizes now accommodate any SCREENMAX changes
  Features
    . made %CPU and 'i' mode handling more efficient
    . for input the Up/Dn arrows keys act as alternatives to Ins/Del keys
   . an optional USE_X_COLHDR define eliminates ALL 'x' toggle overhead
    . an optional ZAP_SUSEONLY define was added for Werner's modifications
  Cosmetic
    . defines and format for optional end-of-job reports standardized
2011-04-14 07:08:14 +10:00
Craig Small
fd62123562 New version of top from Jim 2011-03-31 22:15:12 +11:00
Jan Görig
9e6370a886 clear screen after fields selection
Author: Tomas Smetana <tsmetana@redhat.com>
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=440694
2010-12-16 10:25:36 +01:00
Jan Görig
0232430bef Fix highlighting problem in top
Author: Paolo Pantaleo <paolopantaleo@gmail.com>
Bug-Debian: http://bugs.debian.org/351065
2010-12-16 10:21:47 +01:00
albert
93fd4a460e not ppc64 2009-12-10 11:37:48 +00:00
albert
6154f23d5a src==dst is illegal, failing on ppc64 2009-12-09 09:28:22 +00:00
albert
7dd414ac1b new /proc/meminfo fields 2008-03-24 04:41:26 +00:00
albert
c0f3df30ca watch: tolerate umlauts 2007-05-28 03:18:52 +00:00
albert
8e4bf3e115 top: normal exit code should be 0 2007-05-27 23:56:49 +00:00
albert
9049ffef32 ps man page 2006-09-10 06:25:56 +00:00
albert
9278134e49 top: show CPU time stolen from a virtual machine 2006-06-25 02:15:36 +00:00
albert
1e73c7b8bc bit of top hacking 2006-06-25 01:14:24 +00:00
albert
89ed9ba210 top: CPU usage column width fixes -- thanks Tony Ernst 2006-06-17 05:20:01 +00:00
albert
58f47c6614 terabytes 2006-01-22 07:57:13 +00:00
albert
73030f7346 top: crash on resize fixed -- thanks Michal Maruska #320289 2005-10-30 05:28:22 +00:00
albert
a402ba1848 fix %CPU max on 2..9 CPU SMP -- thanks Ga*tan LEURENT 2005-09-12 01:27:59 +00:00
albert
38d36b4960 top can show loose tasks now 2005-06-21 19:20:39 +00:00
albert
6e183316de no C99 variable declarations just yet 2005-01-26 07:55:52 +00:00
albert
33721d7e57 document #C to P change 2005-01-06 00:49:09 +00:00
albert
95cc4c37bb variable-width %CPU,PPID,PID 2005-01-06 00:13:12 +00:00
albert
aae3e72ab7 help and version message on stdout, with exit(0) #283541 2005-01-05 20:29:26 +00:00
albert
54ecbe0a8a consider "T" state as idle -- thanks Eric Laroche 2004-11-30 16:11:24 +00:00