During the changes to procps_loadavg I didn't set the initial
value for retval, meaning it was a random number.
It is now correctly intialised to zero.
References:
commit 8fcd14de18
Now that the library correctly returns an error if loadavg
is not available, tload can tell the user the bad news.
References:
procps-ng/procps#227
commit 8fcd14de18
Signed-off-by: Craig Small <csmall@dropbear.xyz>
A library should generally return an error value, rather than
printing to stderr a message. procps_loadavg() had a few things
to change:
It had a global buffer, but we don't call this function over and
over except in tload. It also did had two macros where a plain
fopen() would do the job nicely.
This removed the macro FILE_TO_BUF which was used everywhere in oldlib
but only for loadavg in newlib.
This library change will set us up to fix tload.
When /proc is mounted with subset=pid free just gives the
standard cannot create meminfo structure without any hint why.
free now checks the return value and if it is -ENOENT then it
gives more information about the problem.
References:
procps-ng/procps#227
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Make the vmstat_read_failed() return non-error for Cygwin as
it always will error because /proc/vmstat doesn't exist.
Patch from Achim of the Cygwin project.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Now that a potential use of that bottom 'window' for a
menu has been demonstrated, we'll remove such clutter.
[ after all, the prior commit cautioned against text ]
[ made conditional which might also be translatable. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
While it is acceptable to make text usage conditional,
one must never make the text itself conditional. After
all, the translators must be presented with all of the
text so the opportunity to translate it is never lost.
[ one wonders who the idiot was that did this anyway ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
Fix some errors introduced in the commits shown below.
Reference(s):
. Apr, 2022 - 'keys_global' missed redundancy
commit 27f5904edd
. Apr, 2022 - added extraneous comma in help text
commit fb32021eeb
Signed-off-by: Jim Warner <james.warner@comcast.net>
If the special bottom 'window' routines remain unaware
of potential multi-byte characters, that heading could
be truncated prematurely and unnecessary blank line(s)
added to the reserved rows at the bottom of a display.
So, in both cases, this patch will now account for any
difference between string lengths and display columns.
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch attempts to reduce the proliferation of the
bottom window support routines by combining the 'misc'
with 'item' functions. Along the way we can now rename
those two 'pick' functions 'menu' while keeping proper
alphabetic order among all the bottom window routines.
Signed-off-by: Jim Warner <james.warner@comcast.net>
pkg-config is used to find various libraries used by procps.
Unfortunately it, or rather automake, give terrible misleading
error messages if pkg-config is not installed.
At ./configure time you get this:
configure: error: ncurses support missing/incomplete (for partial
build use --without-ncurses)
At automake time you get this:
configure.ac:33: error: possibly undefined macro: AC_MSG_ERROR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:48: error: possibly undefined macro: AS_IF
configure.ac:113: error: possibly undefined macro: AC_DEFINE
The internet is filled with such wonderful other examples.
This commit does two things:
At autoconf time, check PKG_PREREQ macro is defined which is found in
pkg.m4 and tells us pkg-config has its macros available.
At configure time, check the result of the pkg-config test and error
if it didn't find it.
Now it actually says its missing pkg-config. To be fair, the autoconf
check is "documented" and recommended in pkg.m4 file.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
The existing build system would only require wide ncurses for
a wide watch and even if the library was there would not link
anything else to it.
The first issue which #123 made me think of, is if ncursesw
was there and ncurses is not, why not use ncursesw?
A more major issue is if programs such as slabtop are linked
to ncurses, then certain languages will display their text
wrong, as found in #237.
The days of assuming ASCII only is ok are over the build system
now does the following:
1. If ncursesw is available use this for all relevant programs
2. If ncursesw is not but ncurses is, use this instead
3. If you enable 8bit watch and either disable ncurses or
we cannot find ncursesw error at configure time.
In related news, I hate M4sh.
References:
procps-ng/procps#123procps-ng/procps#237
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Reference(s):
proc/uptime.c:191:9: warning: variable 'uphours' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
Signed-off-by: Jim Warner <james.warner@comcast.net>
Really, extend shift+tab navigation to only some linux
consoles (or maybe most consoles). However, there were
some consoles where shift+tab always yields just '\t'.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Since top now uses string vectors for two items in the
new focus window (cmdline & environ), there is no real
use for that 'separator' specified at toggle time. So,
this commit will find a new use for what is the space.
Henceforth, when a user is navigating using the tab or
backtab keys, should a strv element with focus contain
embedded space(s), it will be emphasized & highlighted
using the current window's message color (capclr_msg).
Signed-off-by: Jim Warner <james.warner@comcast.net>
A commit that changes no code but, hopefully, helps to
better document where and how such literals were used.
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit adds a new option called `--equexit` which is the opposite
of `--chgexit`. This option makes it possible to exit when the output
of the given command does not change for the given number of cycles.
A download operation could be given as a use-case since `watch` will
exit when the output does not change anymore, in other words, when
the download is completed.
References:
procps-ng/procps#232
Signed-off-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Merge request 154 brought up the issue of the space before the commar
after sigaction, however the MR included the translated generated
pages.
References:
procps-ng/procps!154
Signed-off-by: Craig Small <csmall@dropbear.xyz>
This commit just brings that 'bot_focus_strv' function
up to the same standard as the vanilla 'bot_focus_str'
guy. Namely, if there is no cmdline or environ for any
process, that bottom window will now display an 'n/a'.
[ with the nature of those string vectors, it wasn't ]
[ the same simple process found for regular strings. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
Some of those bottom windows grow quite large, as with
the firefox environment. If one is navigating the data
using the tab key, it can be very inconvenient when an
element should be reexamined but that focus has moved.
Therefore, this commit will support the 'back_tab' key
which is a standard combination of the shift+tab keys.
Now a user can easily backup up to any missed element,
assuming a terminal emulator honors that terminfo key.
[ a gui emulator typically will honor the 'back_tab' ]
[ terminfo string, whereas a linux console does not. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
Using 'mempcpy' was a mistake where plain old 'memcpy'
was appropriate. More importantly, the careless length
specified resulted in a SEGV under some circumstances.
[ namely, it occurred under a multi-threaded top and ]
[ the top program itself as focus + CtrlN 'environ'. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
After satisfying increased buffer size in the previous
patch, I decided to improve the highlight accuracy for
both the command lines plus the environment variables.
Since they both may contain elements which themselves
include embedded spaces, to accomplish this goal, one
must trade vanilla strings for string vectors instead.
[ at last such library items have now been justified ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
As it turns out, some of the 'environ' strings are big
enough to overrun the initial buffer sizes. And, while
no real harm was done (other than to silently truncate
the output), this patch will increase the buffer size.
While we're at it. we will normalize a few more buffer
declarations along with correcting a couple typos too.
Signed-off-by: Jim Warner <james.warner@comcast.net>
[ and along the way, those 2 newest namespace fields ]
[ are now mentioned under that same 'X' command part ]
[ this commit already changed for improved response. ]
[ they should have been included in the patch below. ]
Reference(s):
commit 6e78355d4d
Signed-off-by: Jim Warner <james.warner@comcast.net>
[ along the way we will restore '^R' to keys summary ]
[ plus correct a leftover reference to 'Ctrl-V' too. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit adds a prototype for a potential extension
of that tabbed bottom window capability. It introduces
a 'menu' which then provides for users' selections. It
does not actually do anything meaningful and will only
be enabled with the new #define called 'BOT_PICK_YES'.
[ since it's just a proof of concept, no attempt has ]
[ been made to add the usual NLS translation support ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit introduces the 'tab' key which can be used
to highlight individual elements in that bottom 'Ctrl'
window. This can really help when reviewing such data.
[ note, normal ongoing monitoring continues unabated ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit adds support for displaying the namespaces
in top's separate bottom 'Ctrl' window. Along the way,
the plumbing is now in place to extend this capability
to other data (if we don't run out of '^' keystrokes).
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch will just set the stage for the next commit
where we'll be adding the capability to display things
that sometimes may necessitate multiple library items.
In that effort we will be adding several new routines.
Signed-off-by: Jim Warner <james.warner@comcast.net>
In that commit shown below, the concept of a corrupted
display was introduced so that 'Ctrl' windows could be
redrawn now that they were made more persistent. Well,
it turns out there is another case where redrawing was
necessary. That is when transitioning between task and
thread modes. So this patch addresses those occasions.
Reference(s):
. May, 2022 - introduced Frames_signal BREAK_screen
commit d66c1f39b5
Signed-off-by: Jim Warner <james.warner@comcast.net>
In the patch referenced below the bottom 'Ctrl' window
was made to remain until it was dismissed by the user.
As such, it required abandoning a 'Cap_nl_clreos' used
when all the terminal rows had not been drawn. Instead
each line had to be cleared individually until the row
reserved for that 'Ctrl' window area had been reached.
Unfortunately, while a 'Cap_nl_clreos' didn't create a
problem for 'batch' mode, a 'Cap_clr_eol' used instead
yielded an unending loop if those rows were limitless.
So, now we will only clear that area when top isn't in
'batch' mode (which should have always been the case).
Reference(s):
. May, 2022 - bottom window made sticky
commit 0f2a755b0b
Signed-off-by: Jim Warner <james.warner@comcast.net>
Well darn it, whoever wrote that new library caught me
with my pants down (again?). Shoot, they were not just
down but somehow missing altogether. Here's the story.
Any item from that library supported by dynamic memory
can only be represented in user's stacks exactly once.
Should any string based enumerator be duplicated among
the items array, for any instance beyond the first the
library will return '[ duplicate ENUM ]' for a result.
That's where I lost my pants. While command lines were
given special handling (and never duplicated) I failed
to turn on CGROUPS, SUPGRPS & ENVIRON when testing the
Ctrl-G, Ctrl-U & Ctrl-N keys. If any of those 3 are on
that's when a Ctrl window sees a 'duplicate' notation.
[ and who runs top with such fields displayed anyway ]
In responding to this oops, the internals were changed
quite dramatically & vastly simplified in the process.
More importantly, the 'duplicate' results are no more.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Change the default name to cons%d
ctty can be used by other systems not just Cygwin so create a define
separate to cygwin for using the ctty function. The autoconf will need
to be updated to check for these specific systems in future.
Thanks to Achim of the Cygwin project for the patches.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
I'm not sure why you would roll your own macros for major and minor
while the standard includes have these defined. Using our versions
causes two problems:
- Some systems don't use this format for their minor/major
- If the kernel proc interface becomes a 64-bit number, like
dev_t is in the library, then our macro will need to be changed.
autoconf already had the check and as a bonus for anyone that
puts these definitions in sys/mkdev.h it handles that too.
So this is now the standard way of getting a minor/major number out of a
device id. Examining bits/sysmacros.h showed that their defines are
close to what devname.c had, except it can handle 64-bit numbers.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Stops the compilier (correctly) complaining:
lib/test_shm.c: In function ‘main’:
lib/test_shm.c:65:23: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘int’ [-Wformat=]
65 | printf("SHMID: %llx\n", shm_id);
| ~~~^ ~~~~~~
| | |
| | int
| long long unsigned int
shm_id is an int which is what shmget() returns.
Strangely pmap has always scanned this in as a llx even though the maps
"inode" column is the same number that shmget() returns.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
Previously the match for shmid was \d+ but the variable is printed
as a hex number, updated the regex to suit.
Added some changes for pmap test so if the test_shm process fails
we just skip past it.
Signed-off-by: Craig Small <csmall@dropbear.xyz>
To complete the implementation of this new feature, we
must address the problem created by any commands which
offer their own full replacement displays. Should that
'Ctrl' bottom window be active, a return from any such
command leaves that lower portion of a terminal blank.
While we could issue a 'TAGGED_TOSS' macro right after
invoking any of those 4 (currently) affected commands,
it is wrong to make them aware of this 'tagged' stuff.
So, I'll opt for a more generalized solution whereby a
notice regarding a corrupted screen is broadcast. Then
the logic already aware of 'tagging' can deal with it.
Signed-off-by: Jim Warner <james.warner@comcast.net>
After making that new bottom window more persistent, I
decided to offer a build choice for somebody who might
prefer to have the rug pulled out from under him while
reviewing window contents should some target task end.
If 'TAGGED_BRIEF' is defined old behavior is restored.
[ it should be noted, however, that when this define ]
[ is active we'll lose any benefit of onetime update ]
[ for the bottom window. just like with the original ]
[ behavior, it is repainted with every update cycle. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>