Commit Graph

1227 Commits

Author SHA1 Message Date
Jim Warner
081fe506f3 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-27 22:08:02 +11:00
Jim Warner
9e99c84c48 top: kill/nice provide for a default pid, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:01 +11:00
Jim Warner
39f4067c66 top: kill/nice provide for a default pid
As an aid to the above 2 commands, and as a prelude to
an upcoming 'inspect other output' capability, the act
of selecting a process for either has been simplified.

Positioning a task as the first one displayed, via the
up/down arrow keys, will now establish it as a default
selection for the appropriate command.  Thus, that pid
will then be incorporated in a subsequent input prompt.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:01 +11:00
Jim Warner
4dfb01aa37 top: quiet lintian with escaped dashes in man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:00 +11:00
Jim Warner
44ceff845b top: include under nls support an overlooked error msg
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-11-27 22:08:00 +11:00
Lyonel Vincent
c29ce7be61 do not complain when negating selection if we can't find a user/group 2012-11-25 17:23:39 +01:00
Craig Small
ce95dd53eb Add -c count option to pkill
Possibly by a side-effect but pkill -c option used to work which would
print the number of killed processes.  This small change restores this
functionality.

Bug-Debian: http://bugs.debian.org/693783

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-11-21 22:11:17 +11:00
Craig Small
c5ee091e4c Updated news for 3.3.5 2012-11-06 23:01:08 +11:00
Sami Kerola
4a6df5b133 ps: cut out code unused code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:30:02 +11:00
Sami Kerola
58713dbcc8 watch: fix compiler warnings
watch.c:255:14: warning: no previous declaration for 'get_time_usec' [-Wmissing-declarations]
watch.c:303:6: warning: no previous declaration for 'output_header' [-Wmissing-declarations]
watch.c:364:5: warning: no previous declaration for 'run_command' [-Wmissing-declarations]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:30:02 +11:00
Sami Kerola
ac97321851 vmstat: fix compiler warnings
vmstat.c:817:7: warning: declaration of 'tmp' shadows a previous local [-Wshadow]
vmstat.c:708:7: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:30:02 +11:00
Sami Kerola
22ceeca4a6 pmap: fix compiler warnings
pmap.c:80:7: warning: declaration of 'mapbuf' shadows a global declaration [-Wshadow]
pmap.c:63:13: warning: shadowed declaration is here [-Wshadow]
pmap.c:137:37: warning: declaration of 'mapbuf' shadows a global declaration [-Wshadow]
pmap.c:63:13: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:30:01 +11:00
Sami Kerola
2c99a09e52 sysctl: fix compiler warnings
sysctl.c:293:5: warning: no previous declaration for 'is_deprecated' [-Wmissing-declarations]
sysctl.c:472:58: warning: declaration of 'pattern' shadows a global declaration [-Wshadow]
sysctl.c:67:14: warning: shadowed declaration is here [-Wshadow]
sysctl.c:650:7: warning: variable 'SwitchesAllowed' set but not used [-Wunused-but-set-variable]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:30:01 +11:00
Sami Kerola
c8554e6c0f skill: fix compiler warnings
skill.c:340:5: warning: no previous declaration for 'skill_sig_option' [-Wmissing-declarations]
skill.c:460:5: warning: no previous declaration for 'snice_prio_option' [-Wmissing-declarations]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:28:30 +11:00
Sami Kerola
9e3c259fae lib/fileutils: fix compiler warnings
./lib/fileutils.c:9:5: warning: no previous declaration for 'close_stream' [-Wmissing-declarations]
./lib/fileutils.c:23:6: warning: no previous declaration for 'close_stdout' [-Wmissing-declarations]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:28:30 +11:00
Sami Kerola
9ba7f3abdb pgrep: fix compiler warnings
pgrep.c:195:12: warning: 'fcntl_lock' defined but not used [-Wunused-function]
pgrep.c:575:5: warning: no previous declaration for 'signal_option' [-Wmissing-declarations]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:27:48 +11:00
Sami Kerola
e677476aea pmap: remove memory leaks
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:26:55 +11:00
Sami Kerola
c043c47ddd pmap: use correct types for memory allocation
Fixes error which did not happen always.  Changes of being affected by
the bug where greater the more there where pids defined as pmap argument.
The debian bug referral can almost certainly reproduce the problem,
especially when tried multiple times in row.

pmap: malloc.c:3096: sYSMALLOc: Assertion `(old_top == (((mbinptr)
(((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct
malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >=
(unsigned long)((((__builtin_offsetof (struct malloc_chunk,
fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) -
1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) ==
0)' failed.

Reported-by: lee <lee@yun.yagibdah.de>
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=688180
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:22:11 +11:00
Craig Small
ee03bb92cb Add missing fileutils test files
Reference: http://www.freelists.org/post/procps/procpsng-version-334-released,7

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-10-31 22:47:48 +11:00
Mike Frysinger
a72fb6accf fix sysctl.conf inclusion in dist tarballs
If you configure w/out --enable-examples, then `make dist` doesn't
include sysctl.conf.  Configure flags should not affect the tarball
produced by `make dist`, so explicitly list the conf in EXTRA_DIST.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-31 22:42:03 +11:00
Craig Small
64fa889816 Stop SIGFPE on vmstat at times
Certain setups can crash vmstat with a SIGFPE, this small patch
catches those events

Bug-Debian: http://bugs.debian.org/677903
2012-10-30 21:48:34 +11:00
Craig Small
ff6c8aad3e Added debian patch for kfreebsd bug 674785 2012-10-30 21:36:04 +11:00
Craig Small
0c74162049 Bump the soname 2012-10-30 21:34:40 +11:00
Craig Small
f7eb5a49a0 w: do not truncate command when width is not known
Merge remote-tracking branch 'sami/2012wk28'
2012-10-26 19:06:16 +11:00
Jim Warner
99010db097 top: tweak scroll coordinates msg handling (again)
An earlier commit improved the scroll coordinates
message performance by offloading most of the work
to those occasions when column headers were rebuilt.

The only remaining per-frame costs were the addition
of some terminfo escapes and the Frame_maxtask count.

This commit further reduces those per-frame costs to
the absolute minimum.

Reference:
commit fbfaa868ba

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-26 18:58:42 +11:00
Jim Warner
0163abb48b top: allow exit from 2nd level help via <Esc> key
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-26 18:58:42 +11:00
Eric Dumazet
7933435584 ps: allow large list of groups
Current linux kernels output no more than 32 groups
in /proc/{pid}/status.

Plan is to increase this limit.

This patch allows ps to not core dump if the buffer used to read status
file was too small.

# ps aux
Signal 11 (SEGV) caught by ps (procps-ng version 3.3.3).
ps:display.c:59: please report this bug

Also increases the size of the buffer from 1024 to 4096, since even with
32 groups we are close to the limit.

cat /proc/12731/status | wc
     39     128     961

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
2012-10-24 21:43:37 +11:00
Craig Small
9a60202b81 pgrep delimeter to delimiter
pgrep used delimiter and delimeter, the correct spelling is delimiter.
Thanks to Alexander Kobel for the heads-up.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-10-11 21:34:50 +11:00
Jim Warner
e77c8e8cf0 top: for performance, employ additional inlining
The 'refactor and enhance column width management'
recent redesign produced many subsequent benefits,
the latest of which is automatically sized fixed-width
non-scalable columns.

As expected, there was a cost associated with these
many enhancements.  That cost has now been identified
as a 1-4% performance degradation, depending on which
fields are being displayed.

This increased cost arises principally from current
drawing related function calls, whereas top-3.3.3 did
most of its drawing via macros effectively inlining
those duties.

This commit inlines the equivalent drawing functions,
thus eliminating the function call penalty, and places
this top on a par with top-3.3.3.  The trade off is a
modest additional 4k in executable size.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:13:14 +11:00
Jim Warner
f005411974 top: 'X' command offers auto option, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:13:14 +11:00
Jim Warner
35cd340002 top: 'X' command offers auto option
The recent introduction of a column widths override
(the 'X' command) provided for a user input amount
to be added to default field size which ranged from
5 to 10 bytes.

While that approach could prevent truncated data, the
different default sizes would almost certainly mean
some precious screen real estate was waisted.

This commit introduces the concept of dynamic widths
where top will add only enough to a field default to
prevent truncation for that specific field.

Now users have a choice between their explicit width
override or a width chosen by top to exactly match
display needs.  The former is immediate but likely
wastes some horizontal space while the latter is
iterative but will be sized precisely.

Original 'X' Command:
commit 384afa494a
commit 47e1d063ac

Extensions to 'X' Command:
commit bbf8e44fb4
commit 7557f3f754

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:13:13 +11:00
Jim Warner
21237356ab top: map additional navigation keys, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Jim Warner
bff927711b top: map additional navigation keys
There were some gaps in the alternate navigation keys
top provided.  Additionally, some inconsistencies
existed in the supporting key table.

This commit adds the following new key equivalents,
mirroring the standard vim navigation keys:
. ctrl+alt+ k = pgup, ctrl+alt+ j = pgdown
. ctrl+alt+ h = home, ctrl+alt+ l = end

Also, the supporting table entries now consistently
follow these "directions":
. up/pgup, down/pgdown, left/home, right/end

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Jim Warner
edd8aae5ba top: avoid potential xterm state corruption
To support the cursor navigation keys, after saving
the termios structure top issues 'smkx/keypad_xmit'
during startup.  However, some terminals appear to
treat that directive as persistent which leaves a
corrupted tty state after top exit.

This commit reverses the above terminal directive
via 'rmkx/keypad_local' just prior to restoring the
saved termios structure at program end.

For discovering this bug, and providing the 'rmkx'
clue to its solution, thanks to:
  Kirill A. Shutemov <kirill@shutemov.name>

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Jim Warner
bb6cc9c159 top: for user justify feature, remember old-top needs
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-11 21:10:44 +11:00
Craig Small
19b6f48990 kill -PID fixed
Bug-Debian: http://bugs.debian.org/688731

kill would not permit negative PIDs and thought they were options. kill
now explicitly checks for unknown options and if they are numeric
assumes they are negative PIDs.  The first negative PID stops any
further option processing.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-10-02 21:56:38 +10:00
Jim Warner
d58dc6b1e7 top: swat a bug introduced with recent width refactor
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
66c87f8ef1 top: update NEWS with additional capabilities
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
7557f3f754 top: with new 'X' command, WCHAN becomes fixed-width
This 'Sleeping in function' field was made variable
width because the length of current kernel symbols
usually exceeded the former top's 9 character limit.

As a variable width field it would steal valuable
horizontal display positions from other, more likely,
displayed fields such as COMMAND or CGROUPS.

With the advent of the new 'X' toggle, no fixed-width
non-scalable field need suffer permanent truncation.
Thus, WCHAN is being made fixed width with a default
size of 10 characters.

Signed-off-by: Jim Warner <james.warner@comcast.net>

 top/top.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
2012-10-02 20:56:40 +10:00
Jim Warner
bbf8e44fb4 top: extend new 'X' command to include the TTY field
I have no idea what the maximum length of a terminal
name might be.  However, the library provides for up
to 128 characters (ouch).

So just to be safe, this commit extends the ability
to widen columns to embrace this field.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
47e1d063ac top: optional wider non-scalable cols, man document 2012-10-02 20:56:40 +10:00
Jim Warner
384afa494a top: optional wider non-scalable cols
This commit accommodates those fields which may have
suffered truncation due to these default limits:
  . 5 digits for uid/gid type fields
  . 8 characters for user/group type fields

With a new interactive command, users can increase the
width of all such fields, or return to the defaults.

Note:
   There are no restrictions on the amount added to
   the defaults.  The user is free to vastly exceed
   screen limits which simply means such fields can
   never be displayed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
46bd0085b0 top: column alignment under user control, man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
c07be1d492 top: column alignment under user control
This commit affords user control over justification
for both column headings and the subordinate data.

Separate toggles are provided for control of numeric
data and string data.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
0f61354bf7 top: refactoring now allows column header nls support
Now that column headings are independent of column
data format and require no carefully managed padding
bytes they are candidates for nls translation.

This commit migrates all column headings to the .pot
file with additional translator guidance in the form
of maximum sizes to avoid truncation.

It also places these new additions adjacent to their
associated descriptions, which were already present.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:40 +10:00
Jim Warner
64cfdda756 top: refactor and enhance column width management
This commit accomplishes the following objectives:
 * remove extra task_show parm added with 'Locate'
 * avoid column overflow with subsequent misalignment
 * eliminate spaces for column heading padding
 * decouple column headings from column data formats
 * eliminate all hardcoded column format specifiers
 * generalize the inter-column spacing management
 * remove Fieldstab.desc in favor of direct nls access
 * set the stage for nls support of column headings
 * set the stage for dynamic changes to justification

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:39 +10:00
Jim Warner
767a13b96c top: tidy up some miscellaneous user input logic
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:39 +10:00
Jim Warner
718cececc7 top: correct an old man document flaw
This flaw was revealed under 'man2htm' and dates back
to the first Gitorious revised top submission.

Reference:
commit fd62123562
Date:   Thu Mar 31 22:15:12 2011 +1100

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:39 +10:00
Jim Warner
6c8e9d9581 library: fix proc_t page fault delta counts alignment
When the maj_delta and min_delta fields were added to
the proc_t, they necessitated some compiler generated
padding bytes.

With this slight reordering, those padding bytes are
no longer generated.  And since the original commit
already broke the library ABI, now is an opportune
time to correct that misalignment.

Reference:
commit 7753bd1004

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-10-02 20:56:39 +10:00
Jim Warner
a65de0fd73 ps: favor truncation of long names over POSIX/UNIX standard
The UNIX and POSIX standards require that user and
group names be printed as decimal integers when there
is insufficient room.  This has led to a constant
stream of bug reports.

With this commit, long names will be truncated and
displayed with a trailing visual clue.

To avoid truncation. the UNIX and POSIX way to change
column width is to rename the column:
   ps -o pid,user=CumbersomeUserNames -o comm

The easy way is to directly specify the desired width:
   ps -o pid,user:19,comm

Reference:
http://www.freelists.org/post/procps/rhbz737215-ps-does-not-resolve-some-user-names

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-09-27 22:16:53 +10:00