Commit Graph

185 Commits

Author SHA1 Message Date
Jim Warner
7b708ca334 top: rename a single Other Filter variable for clarity
There is a member of the osel_s structure called 'flg'
that is used to reflect whether a particular filter is
one of inclusion or exclusion (negation). So by golly,
from now on we'll refer to it as 'inc', and not 'flg'!

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-14 12:36:47 +01:00
Jim Warner
d7f3a80e18 top: improve man doc Section 5e, FILTERING in a window
This commit involves very little content change and is
more concerned with better formatting for readability.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-14 12:36:47 +01:00
Jim Warner
2872d24362 top: correct a sightly obsolete nls 'Translation Hint'
When the command line sort override provisions (-o/-O)
were added, the usage text was modified to keep within
an 80 column terminal but the nls hint didn't keep up.

Reference(s):
commit 407d1fc8f2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-14 12:36:47 +01:00
Jim Warner
1a50f39971 top: fine tune (ie. fix) 'other filter' negation logic
Two too many of these '=' (cooks) spoiled top's broth.

There exists an unintentional variation on the classic
error: off-by-one. When a negation symbol is used with
top's new relational 'other filter' provision, one too
many 'matches' are excluded. This happened because top
covered only 2 of the 3 potential strcmp return codes.
When the strings were equal, they were simply dropped.

So this patch will uninvent that particular variation!

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 2c2c5f5cd2

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-07 17:55:20 +01:00
Jim Warner
ef99eebbdb top: introduce relational operators, plus man document
References:
http://www.freelists.org/post/procps/top-beyond-infinity,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-06 14:37:41 +01:00
Jim Warner
2c2c5f5cd2 top: introduce relational operators with other filters
When I originally entertained thoughts of maybe adding
relational operators to the new 'Other Filter' feature
the programming challenges seemed just too great. Yet,
when Jaromir suggests its desirability it now suddenly
becomes a reality. Another of life's little mysteries!

At any rate what was already an extremely powerful new
feature is even better by several orders of magnitude!

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

References:
http://www.freelists.org/post/procps/top-beyond-infinity,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-06 14:37:40 +01:00
Jim Warner
f9a208b273 top: enable other filtering, add documentation support
This commit provides the hard copy support for our new
'Other Filter' feature. The man document contains some
potentially useful examples and it will be interesting
to see what use this new tool is put to in the future.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-04 18:46:37 +01:00
Jim Warner
5edc6fb317 top: enable other filtering via inclusion or exclusion
This change represents the extension of user filtering
based on inclusion or exclusion. However where 'U'/'u'
filtering provides an either/or choice, this extension
offers multiple choices applicable to multiple fields.

The 'inclusion' and 'exclusion' criteria can be freely
combined making a powerful tool to fine tune a display
and avoid clutter associated with uninteresting tasks.

I'm convinced it offers unimagined future flexibility!

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/top-over-the-top,22
http://www.freelists.org/post/procps/top-over-the-top,8

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-04 18:46:34 +01:00
Jim Warner
5e4bade595 top: minor refactor in preparation for other filtering
While it's only documented (so far) in commit text and
an occasional email I've tried to maintain some coding
standards primarily for reference/navigation purposes.
They also served, I felt, as useful mental challenges.

Someday I will get around to formerly documenting them
but in the meantime here are the ones for this commit:

. functions are grouped into logical (i hope) sections
. functions & sections are ordered to avoid prototypes
. function names are alphabetical within every section

Thus, given those constraints/objectives, and in order
to prepare for an upcoming Other_Filter feature, a few
things had to be renamed and rearranged. Plus a couple
of other (unrelated) tweaks were made for consistency.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 270e8e7eeb
http://www.freelists.org/post/procps/PATCH-12-top-restore-terminal-state-on-exit,4

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-04 18:46:31 +01:00
Jim Warner
b9976f7056 top: finish the job of correcting the response to a ^Z
if top is suspended while on the 2nd level help screen
the <Enter> key is no longer honored. Thus, users must
use <Esc> to exit help and return to the main display.

Also, line input that was only partially complete when
suspended would still require one additional keystroke
before the read was aborted and the display refreshed.

Lastly, some user interactions might require two input
lines before an operation can be considered completed.
Thus the 2nd line offers another opportunity for users
to suspend top. Resumption would require an extra key.

These issues stem from 2 recent enhancements: preserve
the user context when signaled; complete input editing
with cursor movement keys, insert/overtype modes, etc.

With this patch, the <Enter> key is once again honored
on help screen #2 and partial reads are now completed.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
       bug reported
http://www.freelists.org/post/procps/top-over-the-top,25
       response to ^Z (partial solution)
commit 5c3fffcf28
       line input editing
commit 477b10c0bd
       preserve context with SIGWINCH
commit ba9092ad83

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-01 14:25:35 +01:00
Jim Warner
709785e20b top: add the field 'USED' to top's existing repertoire
After revisiting the issue of a new field, combining 2
existing fields (RES and SWAP), I've decided it indeed
makes sense. After all, with the vastly expanded field
capability and the ease of adding new fields, it would
save some precious horizontal screen real estate while
also eliminating some mental/manual user calculations.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/top-enhancements-i-hope
http://www.freelists.org/post/procps/top-regression-reports

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

 top/top.1     |   23 ++++++++++++++---------
 top/top.c     |   14 ++++++++++++--
 top/top.h     |    6 ++++++
 top/top_nls.c |    3 +++
 4 files changed, 35 insertions(+), 11 deletions(-)
2013-03-01 14:25:31 +01:00
Jim Warner
9dd7251ca3 top: consolidate logic dealing with resetting a window
This commit just gathers all the logic associated with
resetting/normalizing a single window in one function.

In the future, should the window structure be expanded
to support added functionality, the act of maintaining
it will have been made a little bit easier, hopefully.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-01 14:25:28 +01:00
Jim Warner
a458871cde top: make user's choice for insert/overtype persistent
When true line input editing with paste capability was
was re-introduced in the commit below, the concept for
the distinct insert/overtype mode was also introduced.
But such a distinction did not survive an <Enter> key.

With this commit, the cursor state is made persistent.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 477b10c0bd

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-01 14:25:22 +01:00
Jim Warner
6d0765a03c top: allow no input with the maximum task ('n') prompt
When both 'kill' and 'renice' commands were changed to
provide a default pid, the 'n' command (maximum tasks)
should have also changed to continue to accept just an
<Enter> key under the get_int function's new protocol.

This patch corrects that behavior, accepting no input.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 39f4067c66

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-01 14:25:15 +01:00
Jim Warner
5ee1286625 top: allow re-ordering of saved line input upon recall
The original implementation of input line recall keeps
strings in the order established when initially added.
With this commit, that has been changed so any matched
string moves to the top of the saved input line stack.

[ well technically not the top since that's occupied ]
[ by an 'empty' string which serves multiple masters ]

Thus, the most frequently referenced strings over time
will percolate up and remain the most easily recalled.
But just in case anybody prefers the strict historical
ordering, a #define can restore the original behavior.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 2efe275512

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-27 17:03:54 +01:00
Jim Warner
5c3fffcf28 top: improve the response to ^Z if awaiting line input
Now that line input offers users full editing freedom,
if top were to be suspended after issuing a prompt for
input, upon resumption an extra keystroke is necessary
to satisfy the outstanding read & refresh the display.

With this patch that extra keystroke is not necessary.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 477b10c0bd

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-27 17:03:51 +01:00
Jim Warner
d497b1025a top: some idiot broke 'idle' mode with u/U 'exclusion'
This patch fixes the single stinkin' source line which
was responsible for breaking the top idle-mode toggle.

Without this change, either 'u' or 'U' must be invoked
just once before the 'i' command would show something.

(yes, everything's perfectly justified once again but)
(i'm not very happy over the need for this damn patch)

Reference(s):
commit d04297843f

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-27 17:03:49 +01:00
Jim Warner
2efe275512 top: enable recall of previous input lines for re-edit
With this commit, users can now retrieve previous line
input for re-editing and/or re-input using the Up/Down
arrow keys (or their aliases). This mirrors the 'bash'
or 'less' interface and represents a major enhancement
achieved via a somewhat minor impact to our code base.

[ 33 lines of code, 5 closing braces & some comments ]
[ all in 1 function, when TERMIOS_ONLY isn't defined ]

Currently, the upper limit for such recallable strings
has been set at 50 but that could be easily increased.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-24 08:43:45 +11:00
Jim Warner
477b10c0bd top: enable true line input editing with paste support
This patch changes the TERMIO_PROXY define back to the
former TERMIOS_ONLY thus changing the top default too.

Plus we can now use true line input editing while also
retaining paste capability. That former native termios
support provided only a limited destructive backspace.

Now we exploit the Left/Right arrow keys, Home/End and
Delete. Plus, the Insert key can toggle overtype mode!

[ The stage is now set for a really huge improvement ]
[ to any user input terminated with the <Enter> key. ]
[ So please stay tuned for the next patch to arrive! ]

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit fa21a6ca81

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-24 08:43:45 +11:00
Jim Warner
d04297843f top: enable user filtering via inclusion and exclusion
With this commit top can now display users which match
a user id/name or just those users which do not match.

The distinction is based on the presence or absence of
a leading exclamation point '!' (C negation operator).

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
Wishlist, http://bugs.debian.org/682086

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-24 08:43:45 +11:00
Jim Warner
c856a80ad5 top: end reliance on strdup not failing & roll our own
Lately, top has begun to rely more and more on dynamic
memory allocations rather than the static buffers that
were found in many of its structures. This was perhaps
most evident in the increasing use of the strdup call.

This commit trades that function call for the internal
equivalent which will protect us from malloc failures.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-24 08:43:44 +11:00
Jim Warner
44e61f0f6d top: man document now properly reflects delay interval
This commit corrects one reference to 'decimal place'.

Even though a running top supports a delay interval of
unlimited precision, and a delay interval of thousands
of a second in the rcfile, we intentionally imply that
any delay interval is limited to tenths of a sec only.

Later in the man document, in section 7a, one finds an
admission that a user can set any desired delay value.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/tt,4

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-24 08:43:44 +11:00
Jim Warner
bc5af4ae51 top: keep cursor hidden after Inspect 'Locate' request
A recent commit, that was intended to normalize cursor
handling, unintentionally exposed the cursor following
an Inspect 'Locate' request. This change will hide the
cursor once again through inst_view_choice's lifetime.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit f3a87cf634

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-24 08:43:44 +11:00
Jim Warner
e2c2bc5a95 top: the third time was charmed for end-of-job reports
When top was changed to allow some core dumps, the two
potential end-of-job reports were disabled by mistake.
Later, that was corrected so that those reports always
were allowed, if the respective #defines were enabled.

However, if there was an early exit via a command line
option or an error, those reports should not be shown.

This commit may have gotten it right on our third try!

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 1da293bf59
commit d747659ad8

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-24 08:43:44 +11:00
Jim Warner
ca76af22ca top: lift the field management 6 col width restriction
When two somewhat cryptic error messages were recently
changed to more user friendly text, the logic limiting
maximum columns was left unchanged at six. This always
was a rather arbitrary limit but now the revised error
message could actually be misleading (ok, a huge lie).

With a 1 line code change (macro actually), this patch
lifts the internal restriction on maximum columns. Now
the real limit is based on a window's physical x-axis.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 5a27c8095e
http://www.freelists.org/post/procps/top-won-the-sigwinch-war,6

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-05 22:11:22 +11:00
Jim Warner
dedaf6e1a8 top: disable tty scrollback buffer to improve SIGWINCH
A scrollback buffer used in several terminal emulators
could be a real inconvenience to a user following some
resize operations. Extra keystroke(s) would frequently
be required in order to properly render top's display.

After much sleuthing we unearthed two terminfo strings
which have the effect of disabling/restoring that darn
scrollback buffer. They were well hidden under a title
of strings 'to start/end programs using cup'. In turn,
'cup' deals with a tty's cursor addressing capability.

We don't care what you call them or what they refer to
so long as they get the job done. And these really do!
Be advised, however, that there are some side effects,
several of which can even be considered as beneficial:

. enter_ca_mode/smcup/ti disables scrollback buffering
( and that's good, it's what we had always hoped for )

. exit_ca_mode/rmcup/te restores the scrollback buffer
( but also restores screen contents existing pre-top )
( which is different from former program end results )
( where that last rendered screen was left untouched )

. the above screen replacement would impact ^Z suspend
( thus we keep the scrollback buffer disabled during )
( the suspend/resume sequence so that the users will )
( have a visual clue that top is suspended not ended )

If a terminal does not support these terminfo strings,
we will revert to top's former behavior at program end
where we position the cursor at screen bottom and then
output a single newline character. This will prevent a
shell prompt from embedding within top's final screen.

This commit's approach has been tested under a variety
of emulators and window managers, many of which linked
with libvte and others that employed their own scheme.
Examples are: gnome_terminal; kde konsole; lxterminal;
terminator; terminology; urxvt; xfce4-terminal; xterm.

I do now believe that the whole SIGWINCH deal is done!

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/top-won-the-sigwinch-war
http://www.freelists.org/post/procps/top-won-the-sigwinch-war,4

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-02-05 22:11:22 +11:00
Jim Warner
5a27c8095e top: make field management window size error non-fatal
Reference(s):
http://www.freelists.org/post/procps/top-won-the-sigwinch-war,3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-30 10:53:49 +11:00
Jim Warner
f3a87cf634 top: normalize miscellaneous putp screen manipulations
This commit standardizes the usage of several terminfo
strings concerned with cursor position and visibility.

Henceforth we will adopt the following informal rules:

. Cap_home vs. Cap_clr_scr is preferred where possible
. Cap_curs_huge will be used with prompts for line i/p
. Cap_curs_huge will be used with help & color mapping
. Cap_curs_hide will be in effect in any other context

We've also added a missing Cap_clr_scr to the 2nd help
screen whenever the SIGWINCH interrupt was recognized.
This prevents a 'duplicated' row from appearing at the
top of the display (when resizing from small to large)
depending on an emulator's scrollback buffer contents.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-30 10:53:49 +11:00
Jim Warner
6f25f956e7 top: a few small adjustments to reduce display flicker
This change involves the Fields Management logic only.

With user position being maintained after signals, the
previous algorithm unfortunately used Cap_clr_eos with
each iteration of the loop. The screen flicker invited
with that choice was not apparent under all emulators.

With this commit, clearing to end-of-screen has become
conditional on whether or not there was a true resize.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit ba9092ad83

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-30 10:53:49 +11:00
Jim Warner
adca737758 top: change default allow/suppress define for SIGWINCH
No top #define is enabled and that constitutes default
behavior. So whenever a default behavior should change
the define must be changed too if it is to remain off.

This commit simply changes top's default behavior with
respect to allowing/suppressing any potential flood of
SIGWINCH during resize operations, if running under X.

Formerly top would block those signals to reduce costs
of repeated refreshes. That yields a requirement where
the user would have to provide another keystroke for a
final display update. That keystroke may not always be
needed now, but it ultimately depends on some terminal
emulator's scrollback buffer. In any case, the cost of
re-sizing may go up a bit, under most window managers.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
commit 4f33b6b8c5
http://www.freelists.org/post/procps/top-won-the-sigwinch-war
http://www.freelists.org/post/procps/top-won-the-sigwinch-war,4
http://www.freelists.org/post/procps/top-won-the-sigwinch-war,5

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-30 10:53:48 +11:00
Jim Warner
3fc8b69c7a top: update man document for current screen & SIGWINCH
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-24 21:29:24 +11:00
Jim Warner
4f33b6b8c5 top: offer define to allow/suppress excessive SIGWINCH
After carefully working our way to the point where the
excessive SIGWINCH interrupts are now throttled, along
comes a commit which reverses all those prior efforts.

Actually it doesn't. It simply allows one to choose if
all those efforts should be reversed or remain active.

Why in the world would you even want to consider that?

Quite simply, to opt for responsiveness over overhead.
Oh, and depending on the terminal emulator used for X,
by enabling this OFF_SIGWINCH #define you will be able
to avoid the need for an extra keystroke after resize.

Besides it was an interesting programming challenge to
see just how few lines of code would be needed to make
it possible. Bottom line? Only 1 source line required!
(actually 0 lines, since the define disables one line)

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/unwanted-topinspect-window-enclosure-with-the-terminal-size-change

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-24 21:29:24 +11:00
Jim Warner
dd357e70e7 top: immunize against window manager flood of SIGWINCH
Whew, it was nip-and-tuck there for awhile but finally
we solved the SIGWINCH overload problem one finds with
most X window managers. Now if a window manager should
try to inundate ol' top with repeated SIGWINCH signals
they won't even be received so can't impact us at all.

And we achieve this miracle having never even issued a
sigprocmask, so all the top code executes with signals
totally unblocked. Intuition suggests it probably rubs
even more salt in the wound, but au contraire mon ami!

The key to our success was simply trading the 'select'
call for its cousin 'pselect'. Not only does that call
provide nanosecond granularity (vs. the former's usec)
but it takes a sigset_t parm which can then atomically
block the troublesome SIGWINCH guy until user input or
optional timeout. Net result? No more signal overload!

Now, if only we could just coax all terminal emulators
into one identical standard buffering scheme plus find
some way to emulate the most recent SIGWINCH, it would
be perfect. We would then obviate the user requirement
of typing yet 1 more key before seeing proper results.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/unwanted-topinspect-window-enclosure-with-the-terminal-size-change
http://www.freelists.org/post/procps/Sourceforge-project,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-24 21:29:24 +11:00
Jim Warner
de6df7d736 top: refactor all the low-level i/o logic for SIGWINCH
This commit primarily involves renaming functions plus
reorganizing logic in preparation for the next changes
which will hopefully yield the 'final solution' to the
excessive SIGWINCH signals under most window managers.

In this specific patch, the most significant change is
the introduction of a new 'ioa' function (io avail) to
focus all logic dealing with unsolicited user keyboard
input and exposed to signals and/or optional timeouts.

That new function is where our signal overload will be
ultimately defeated, if it is at all humanly possible.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/unwanted-topinspect-window-enclosure-with-the-terminal-size-change

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-24 21:29:23 +11:00
Jim Warner
ba9092ad83 top: preserve current screen when receiving a SIGWINCH
Prior to this commit, top has always taken the easiest
(safest?) approach when dealing with those troublesome
SIGWINCH interrupts. Whenever the user was on a screen
other than the main display, any signal received would
force an immediate exit, returning to the main screen.

With these changes, top will retain the user's current
position regardless of what screen he/she was viewing.

In support the following additional changes were made:
* the initial help screen requires an explicit end key
` not 'any other key' formerly used to request an exit
* the colors mapping screen instructions were improved
* ^Z response was made immediate, eliminating the flag
* the sigaction's SA_RESTART flag had to be eliminated
* sigprocmask logic was normailize to the bare minimum
* the POSIX.1-2004 async-signal safe functions used in
` the signal handlers were acknowledged and documented

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
http://www.freelists.org/post/procps/unwanted-topinspect-window-enclosure-with-the-terminal-size-change

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-24 21:29:23 +11:00
Jim Warner
5856919e83 top: even more miscellaneous accumulated modifications
This commit just addresses the following minor issues:

. eliminate the leading tab character upon error exits
. standardized single key input as 'keyin', not 'chin'
. symbolic keys changed to guarantee no negative value
. placed most 'case' statement labels on a unique line
. standardized lvalue/rvalue convention in while loops
. fixed prototype declaration in the 'debug_END' macro

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-24 21:29:22 +11:00
Jim Warner
7060f9ab3a top: circumvent an ncurses version 5.9.20121017 glitch
Some testing under a new distro revealed what appeared
to be a broken top Inspect request. When the selection
was made, the resulting output was scrambled/scrunched
at the bottom of the screen (as if ^J's were missing).

This anomaly surfaced under Fedora-18 which happens to
use the above ncurses version. The bug was not present
in version 5.9.20120714 (available with openSUSE 12.2)
or the more widely available version of: 5.9.20110404.

It has now been confirmed that this problem originated
in version 5.9.20120825. It was then that buffering of
output was changed from stdio to some internal ncurses
scheme so as to avoid problems with its SIGTSTP logic.

Thanks to a very prompt response from Thomas E. Dickey
we also learned that contrary to the documentation the
putp logic does not call putchar internally. Thus, the
single putchar that Inspect was employing was actually
mixing 2 different buffering schemes: ncurses & stdio.

Thus, from now on we'll use putp() exclusively and try
to achieve single char output as efficiently as we can
while meeting that putp() string argument requirement.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Reference(s):
https://bugzilla.redhat.com/892674

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-23 21:23:36 +11:00
Jim Warner
d9f7c76114 top: prevent display corruption in Locate highlighting
There existed a small chance that the display could be
corrupted when a search string was found within a row.
For that to happen, conditions like these were needed:

. a very short Locate string was active in some window
. the string matched part of a terminfo <esc> sequence
. that sequence was used in highlighting running tasks
. the 'x' toggle was active (sort column highlighting)

One solution to this potential problem was to manually
turn off sort column highlighting before using Locate.
But rather than rely on a user remedy, we'll automate.

Since other top provisions were already being enforced
when Locate was in use (off 'i' and/or 'u'/'U'), we'll
now also force column highlighting off when the search
string in a given window is not empty. However, unlike
idle tasks and user filtering, when that search string
*is* emptied, we restore highlighting for that window.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-23 21:23:36 +11:00
Jim Warner
1da293bf59 top: accumulated miscellaneous code and comment tweaks
This commit just addresses the following minor issues:

. restored both lost end-of-job reporting capabilities
. added missing initializers to the DEF_RCFILE #define
. added 'nls_maybe' eye-catcher to the 'Scaled_sfxtab'
. removed a now superfluous 'READMINSZ' assertion test
. man document references to 'top' are more consistent

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-23 21:23:36 +11:00
Jim Warner
dec6b8ffe7 top: happy new year while incrementing copyright dates
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-23 21:23:35 +11:00
Jim Warner
b01946742b top: eliminate task row anomalies with active searches
This potential problem is caused by frequently spawned
and short lived tasks which happen to sort above a row
containing a match from an active Locate request. It's
most likely to be visible when under Forest View mode.

This commit will eliminate a potential duplicated row.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-01-01 12:20:17 +11:00
Jim Warner
6c67c8d27a top: tweak the help screen text and termcap attributes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-26 09:11:19 +11:00
Jim Warner
a93f23e6ef top: place inspect demo buffer on par with read buffer
Both of the 'file' and 'pipe' Inspect read buffers are
always 2048 bytes bigger than is actually needed which
provided for some slightly simplified row paint logic.

However, with no real rcfile inspect entries, and thus
operating in 'demo' mode, the allocated buffer is only
2048 bytes total. This can produce a valgrind warning.

This commit simply puts the inspect 'demo' buffer on a
par with other allocated real buffers (an extra 2048).

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-26 09:11:18 +11:00
Jim Warner
9236b39f32 top: add '0' toggle (zero suppress) to the help screen
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-24 08:59:57 +11:00
Jim Warner
ebf4d6dbba top: just touch up some comments for esthetic purposes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-23 06:48:36 +11:00
Jim Warner
2304af908c top: extend command line sort field override provision
In a effort to anticipate a potential future wishlist,
the recent '-o' sort override command line switch will
now support an override of the sort direction as well.

By prepending a '+' or '-' to any valid field name the
user will be able to guarantee a specific desired sort
direction. The '+' forces a high-to-low (normal) order
while a '-' reverses that to yield a low-to-high sort.

Without this addition users would be left to the mercy
of whatever was last specified for Curwin as reflected
in the rcfile or top's default of a high-to-low order.

(everything is perfectly justified plus right margins)
(are completely filled, but of course it must be luck)

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:11:34 +11:00
Jim Warner
2e7adced74 top: extend scaled process memory range to include PiB
The recent change to task area memory scaling was just
a little short of optimum in its consistency and upper
limits. In fact, top could only scale memory fields up
to a maximum of 99.9999 TiB (with VIRT a little more).

While that seems like more than enough it was actually
artificially low, due to an unnecessary decimal place.

So, this commit standardizes both precision and widths
to achieve a minimum amount of scaling beyond the user
requested target plus reclaim some horizontal spacing.

. VIRT & DATA are now 7 bytes wide (not eight and six)
. other memory fields are 6 wide (were formerly seven)
. as before, KiB shows whole numbers only (no decimal)
. MiB, for its precision, shows a single decimal place
. all other memory ranges display three decimal places

The net result is a more homogeneous display with less
forced scaling and the recovery of three lost columns.

(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-enhancements-i-hope,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:10:12 +11:00
Jim Warner
e6cb40235e top: extend scaled summary memory range to include EiB
This commit increases the upper limit for summary area
memory scaling to 9999.999 Exbibytes. It also enhances
the man page through a helpful table for equivalences.

(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
http://www.freelists.org/post/procps/top-enhancements-i-hope,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:10:12 +11:00
Jim Warner
7b1f8fb173 top: enable foreign users under 'u'/'U' task filtering
This commit will allow user filtering as long as there
is a valid number representing a potential user ID. It
will serve, for example, chroot environments where the
specific user may be unknown to a host, or vice versa.

(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-enhancements-i-hope,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:10:12 +11:00
Jim Warner
9f4e72b208 top: do not catch SIGHUP, when operating in batch mode
This commit was adapted from the openSUSE patch, whose
original comments appear between the --- marker below.

It should be noted, however, that the original changes
were ineffective (wasted) because 'Batch' mode had not
yet been set when signals were being checked and their
handlers established. Thus, SIGHUP was never bypassed.

(of course, only our comments are perfectly justified)

------------------------------------------------------
Do not setup SIGHUP signal handler if we are in the batch mode

Top enables a signal handler for the SIGHUP signal (loss of terminal).  While
this makes sense for top's default interactive mode, it doesn't make any sense
for batch mode. If you run top in nohup just to collect data over time and
disconnect top finishes which is not what one would expect.
------------------------------------------------------

Reference(s):
http://www.freelists.org/post/procps/top-enhancements-i-hope,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
2012-12-22 17:10:11 +11:00