On occasion, even as the top author, I wonder why that
'x' toggle has stopped working. Of course, it actually
was working but a locate request ('L') or other filter
('O') operation was active and thus temporarily turned
if off. Such behavior is documented in top's man page.
Well, with this patch that 'x' suppression is no more.
[ the original justification, however, remains true. ]
[ but there's really only one character which causes ]
[ any potential trouble & i'm gonna' keep it secret. ]
[ besides, if a display is corrupted, there's always ]
[ that '=' key which restores things back to normal. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
On Cygwin systems use a different file and format to get the
OS version.
Thanks to procps Cygwin maintainer Achim!
Signed-off-by: Craig Small <csmall@dropbear.xyz>
While the previous commit checked for a GNU environment so Hurd
compilied ok, this tripped up Cygwin. configure now explicitly tests
for the structure field rather than trying to guess through compilier
flags about what the environment tells us about signals.h
References:
commit d39d9db079
Signed-off-by: Craig Small <csmall@dropbear.xyz>
As a result of the issue referenced below, we'll trade
our homegrown offset generator for an 'offsetof' macro
found in the stddef.h header file. This pleases clang.
[ and thanks to Daniel Kolesa for the report and fix ]
Reference(s):
. bug report & recommended solution
https://gitlab.com/procps-ng/procps/-/issues/235
. clang error message
proc/readproc.c:673:9: error: initializer element is not a compile-time constant
mkENT(Rss),
^~~~~~~~~~
proc/readproc.c:661:34: note: expanded from macro 'mkENT'
#define mkENT(F) { #F ":", -1, (int)((void*)&q->smap_ ## F - (void*)&q->fZERO) }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Jim Warner <james.warner@comcast.net>
It would appear that openSUSE was the first to release
procps-ng version 4.0.0 (in the tumbleweed distro). As
a result I checked their source rpm and found a couple
of patches I'm porting to newlib for the next release.
This particulate patch, with some changes, is openSUSE
patch 'procps-ng-3.3.10-large_pcpu.patch'. The changes
were strictly cosmetic. They involved whitespace only.
[ it should be noted that the net effect for raising ]
[ the maximum is to produce a '?' in the %CPU field. ]
[ that's because its width is fixed at five columns. ]
[ but at least the '?' won't distort actual results. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
It would appear that openSUSE was the first to release
procps-ng version 4.0.0 (in the tumbleweed distro). As
a result I checked their source rpm and found a couple
of patches I'm porting to newlib for the next release.
This particulate commit was a refactor of the openSUSE
patch 'procps-ng-3.3.8-bnc634840.patch'. Unfortunately
their original patch did not have the intended effect.
That was because the amended signal handling logic was
performed well before the command line parameters were
parsed. So the global 'Batch' flag was in its 0 state.
. what follows is the original openSUSE commit message
------------------------------------------------------
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.
------------------------------------------------------
Signed-off-by: Jim Warner <james.warner@comcast.net>
When the globbing update was put into sysctl, you could no longer
simply use the keys because one key could potentially be
multiple paths once the glob expansion occured. Using the path
instead gave a unique output.
Except certain programs, such as salt, expected the output to use
the dotted path "kernel.hostname" and not "kernel/hostname".
We can no longer use the original key, so now for each path:
Copy the path
strip off /proc/
convert all / to .
The sysctl testsuite was also updated to check for a few different
types of conversion failures.
References:
commit 6389deca5bhttps://www.freelists.org/post/procps/some-procpsn4400-fixes,4https://repo.saltproject.io/
Signed-off-by: Craig Small <csmall@dropbear.xyz>
With the commit referenced below a nasty bug affecting
aix parsing was swatted. Beyond the bug, the logic was
enhanced to disallow commas in the format string since
they would otherwise be shown with their field's data.
However, there remained many characters other than ','
that could survive the edits to then be shown adjacent
to the data. Well, with this patch they won't anymore!
[ along the way we will no longer try to forgive the ]
[ use of a double '%%' prefix since that resulted in ]
[ display of one '%' and field code instead of data. ]
Reference(s):
. March, 2022 - restored aix bahavior
commit 8cb646bdfc
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit will once again display threads when using
the -L option along with any of those pidlist options.
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/234
Signed-off-by: Jim Warner <james.warner@comcast.net>
The commit shown below broke the aix behavior that Dr.
Fink recently reported. However, in the proposed patch
the old behavior, showing garbage when '%cpu' was used
with an invalid formatting option, would appear again.
So this patch, based on Werner's patch, goes the extra
distance to prevent that. Along the way we'll disallow
commas in the aix format str to prevent their display.
Reference(s):
https://www.freelists.org/post/procps/Procpsng-400-released-with-newlib,2
. Mar, 2022 - where aix bug was introduced
commit 81df85a1b5
Prototyped-by: Dr. Werner Fink <werner@suse.de>
Signed-off-by: Jim Warner <james.warner@comcast.net>
When top's rcfile was reorganized, trading that 'char'
based field representation for the 'int' scheme, there
was a function prologue that should have been changed.
Thus, this patch will correct that original oversight.
Reference(s):
. Mar, 2022 - rcfile reorganized
commit 46aa96e438
Signed-off-by: Jim Warner <james.warner@comcast.net>
Sometimes due to race conditions or the way dejagnu gates the
output, or even there is another interesting process, the ps tests
sometimes fail. These changes make it a little more lenient without
losing the purpose of the test.
Replaces Debian patch ps_tests
References:
https://salsa.debian.org/debian/procps/-/blob/debian/2%253.3.17-7/debian/patches/ps_checks
In some build systems, such as the Debian pbuilders, the
environment is strange. The tty is called "TTY" which causes
some of the ps tests to fail.
This commit checks for that specific result and returns ""
so the tests can be bypassed.
Replaces Debian patch fix_checks.
References:
https://salsa.debian.org/debian/procps/-/blob/debian/2%253.3.17-7/debian/patches/fix_checks
For some unknown reason, make check doesn't depend on either
the check programs or the actual programs under test. This means
if you try to run make check right off the bat from a clean git
repositorty, it will fail as it won't be able to run the unbuilt
binaries.
I'm not sure why this is needed, but if the dist_man_MANS
variable is not copied from the top-level Makefile down to the
man-po one then make dist from a clean archive will not work.
I'm sure someone with better automake magic than me can make
this more elegant but for now it works if a little ugly.
References:
https://www.freelists.org/post/procps/important-newlib-patches,8
When we transitioned from 'char' based fields to 'int'
proper initial cursor positioning (highlight) was lost
in the 'fields_utility' function. The highlight should
appear on the current sort field. Instead, however, it
was often positioned on the first field listed or some
completely different field other than that sort field.
So this patch will restore the master branch behavior.
[ and on the assumption that a sort field is visible ]
[ we will search first for a field with the 'on' bit ]
Reference(s):
. Mar, 2022 - trade 'char' for 'int'
commit 46aa96e438
Signed-off-by: Jim Warner <james.warner@comcast.net>
At this point I don't know if the Rc.id ever carried a
value of 'b', 'c', 'd' or 'e' in a public release. But
I do know that those values ought not to be recognized
in any configuration file. Now they won't be for sure.
[ the net result is that now a user with such a file ]
[ will see the 'incompatible rcfile' message instead ]
[ of that misleading 'window entry corrupt' message. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
When the configuration file is first written, there is
just the normal single newline which ends that rcfile.
However, when any existing rcfile was rewritten, there
was one extra newline '\n' character added at the end.
This will happen just once. The file does NOT continue
to grow with the extra blank lines always being added.
Anyway, this patch will put an end to such a practice.
[ along the way i fixed an unrelated whitespace oops ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
When %CUC was added in the commit shown below I failed
to update the man document. This fixes that oversight.
Reference(s):
commit cfa5538832
Signed-off-by: Jim Warner <james.warner@comcast.net>
This new integer based version of 'fieldscur' deviated
a bit too much from that character based logic when it
comes to ancient 3.2.8 rcfile support. This results in
an inappropriate extra field shown as the last column.
If we're truly dealing with 20 year old 3.2.8 rcfiles,
it's important the 3.3.9 extension (RCF_PLUS_H) not be
concatenated to what was read. That's because a search
for the special SUSE characters will always find a '\'
in the 26th position (after normal 3.2.8 'fieldscur').
[ for symmetry, we'll also avoid RCF_PLUS_J (3.3.17) ]
All other 'old' rcfiles are transformed without error.
Reference(s):
. Mar, 2022 - 3.2.8 support restores
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch will restore the previously abandoned older
rcfile support. To be honest, I wasn't sure this would
be possible given the vast difference between formats.
But after some very intense hacking our newlib top can
again fully support seamless migration from some older
'char' based file to this new 'int' based file format.
[ top even supports a 20+ year old 3.2.8 config file ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
As I speculated in a prior commit, this patch will now
demonstrate how simple it is to extend the upper limit
of supportable fields. With these changes we'll now go
from facing the old limit of 86 to a new limit of 100.
No other changes are needed nor is any logic impacted.
Signed-off-by: Jim Warner <james.warner@comcast.net>
With each of those references shown below, the maximum
number of fields was increased. However, with a 'char'
based implementation we're nearing the upper limits of
total displayable fields. We currently use 76 of a max
of 86 fields. With extra effort, 94 might be possible.
But 94 is the absolute upper limit of possible fields!
Moreover, the current implementation yields characters
that were unprintable in the rcfile. This could become
an issue with that 'inspect' feature when/if an rcfile
is edited to add entries (as opposed to using 'echo').
So, with this commit the internals of field management
has been completely reimagined. It is now based on the
integer type, not a character. And whereas that former
design used the high order bit to show the 'on' state,
thus yielding an unprintable character, the new design
uses the low order bit for the state. As such, numbers
will be kept small and an even number will be an 'off'
field whereas an odd number will become an 'on' state.
The bottom line is that this new design will afford an
unlimited number of new fields while keeping an rcfile
completely free of that potential unprintable garbage.
And it is embarrassingly easy to extend the maximum of
supportable fields from the currently implemented 100.
Who knows, maybe a future patch will prove this point.
[ unless a subsequent commit proves otherwise, given ]
[ the dramatic differences in rcfile contents, i had ]
[ to abandon the practice of supporting old rcfiles. ]
Reference(s):
. Nov, 2013 - RCF_PLUS_H introduced
commit af4e6533ba
. Jul, 2016 - RCF_PLUS_J introduced
commit d5c5051fb3
Signed-off-by: Jim Warner <james.warner@comcast.net>
This warning was added after discovering openSUSE uses
the option with (at least) their 'tumbleweed' version.
The man document sections impacted are: 4e, 5d and 5e.
That is where it was asserted sort column highlighting
would be temporarily turned off if search ('L') and/or
filtering ('O') is active. This option makes it false.
[ shame on suse for not also correcting the man page ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit just compliments a change referenced below
by providing the value which includes reaped children.
[ as an aside, it looks like ps only includes reaped ]
[ children values under an obscure BSD or GNU option ]
[ so, this change is possibly of even more relevance ]
Reference(s):
. Mar, 2022 - added %CUU
commit 2ac72e2e80
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit just compliments a change referenced below
by providing the value which includes reaped children.
Reference(s):
. Feb, 2022 - added %CUU field
commit 7647e96b0a
Signed-off-by: Jim Warner <james.warner@comcast.net>
Some items in the <pids> API carry a '_C' suffix which
implies such values include reaped children. So, we'll
now extend this practice to that new UTILIZATION item.
Reference(s):
. Mar, 2022 - tweak PIDS_UTILIZATION
commit 9c0e8e9429
. Feb, 2022 - added PIDS_UTILIZATION
commit c69104b2b8
Signed-off-by: Jim Warner <james.warner@comcast.net>
When %CUU was added, in the commit referenced below, I
stated that 4 similar specifiers already existed. Well
I misspoke since there is actually 5 including 'util'.
Each of those fields had no sort capability. Since the
values are dynamically calculated, they were forced to
use 'PIDS_extra' as the format_array 'sr' designation.
Now each will use 'PIDS_UTILIZATION' and be sort-able.
[ yes, sometimes the calculated values could contain ]
[ reaped children while the sort field does not. but ]
[ such disparity depends on obscure bsd/gnu options. ]
Reference(s):
. Mar, 2022 - added %CUU
commit 2ac72e2e80
Signed-off-by: Jim Warner <james.warner@comcast.net>
When scale_tics was refactored and then Ctrl-E support
added to top, the complete range of scaling values was
not visible. Namely, a single 'd' (days) & 'w' (weeks)
was never seen with ^E. With this commit they will be.
Reference(s):
. Mar, 2022 - introduced ^E tics scaling
commit 402bf1903b
. Mar, 2022 - refactored scale_tics
commit 71eb90c1b2
Signed-off-by: Jim Warner <james.warner@comcast.net>
Whoa, my head really hurts but this commit should help
with a speedy recovery hopefully, after it is applied.
If the '%cpu' field is used as a format specifier with
that 'o' option, you will encounter a SIGSEGV if there
is also an invalid argument on that same command line.
For example, try 'ps/pscommand -o %cpu,x' with newlib.
With any format specifier other than the '%cpu', there
is an error message, as would happen with '-o pcpu,x'.
For a 3.3.17 version of ps, there's no abend. Instead,
the program will just display a bunch of gobbledygook.
This boo-boo was found to exist as far back as v3.3.0.
[ ok, i am starting to feel very much better already ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
This just parallels the top program by adding that new
library PIDS_UTILIZATION item to the ps repertoire. It
should be noted, however, that the new %CUU field is a
little redundant. I mean, ps already has 4 such fields
implemented identified as: '%cpu', 'c', 'cp' & 'pcpu'.
Oh well, at least the newest one offers a little value
added in the form of extra precision. We'll follow the
top lead and display results in the form of: '##.###'.
Signed-off-by: Jim Warner <james.warner@comcast.net>
When preparing the ps program for a %CUU field, it was
revealed the PIDS_UTILIZATION item may sometimes yield
a result of 'nan' or 'inf' for that ps program itself.
Apparently, it was caused by the short lived nature of
such a one-shot program. And, while this anomaly could
be handled in ps, the solution belongs in the library.
So, I reworked an item's algorithm to avoid this oops.
Signed-off-by: Jim Warner <james.warner@comcast.net>
[ i also tweaked that 'STARTED' narrative just a bit ]
[ since its original wording implied the value could ]
[ change, whereas it's fixed when a task is started. ]
Signed-off-by: Jim Warner <james.warner@comcast.net>
That normalization of the 'scale_tics' function in the
prior commit convinced me that I won't please everyone
with my arbitrary choices for the scaling transitions.
So, this patch will provide the users with a means for
setting their own scaling transition points with a new
toggle. Ctrl-E was chosen since the 'e/E' toggles were
already present as a means of scaling (albeit memory).
[ this toggle will also serve an educational purpose ]
[ by allowing one to see all the scaling conventions ]
The scaling a user establishes is saved in the rcfile.
Signed-off-by: Jim Warner <james.warner@comcast.net>
This patch refactors the 'scale_tics' function to more
closely parallel uptime shown on the first line of the
summary area. The old logic has been preserved through
the header file's new #define SCALE_FORMER provision.
However, the former logic was actually a big disaster.
These are some potential problems with that old logic:
1. With respect to our time fields top no longer deals
solely with cpu time. So, the old limits of '68 weeks'
could possibly be insufficient to reflect those times.
2. Given the widths of top's new time fields, the code
never got beyond scaling to hours. For example, with a
ridiculously large span of 19 years, the scaled result
would then be shown as '167832h'. We never reached the
days ('6993d') or even the weeks ('999w') equivalents.
3. Similarly, with that 'TIME+' field and a large tics
value, results would then appear as 'MMMMMM:SS' rather
than the more meaningful 'HH:MM:SS' or days and hours.
So henceforth we will adopt these scaling conventions:
MMM:SS.hh ... minutes:seconds.hundredths
MMM:SS ...... minutes:seconds
HH,MM ....... hours,minutes
D+H ......... days+hours (with 'd' & 'h' suffixes)
D ........... days (with 'd' suffix)
W+D ......... weeks+days (with 'w' & 'd' suffixes)
W ........... weeks (with 'w' suffix)
Note that, unlike our former scaling logic, that 'MMM'
portion won't be allowed to grow unconditionally. It's
limited (arbitrarily?) to 360 total minutes (6 hours).
Additionally, the 'HH' guy will be limited to 96 hours
(4 days) while that 'D' limit was set at 14 (2 weeks).
Whenever a limit is hit, scaling will advance a level.
Reference(s):
. Feb, 2022 - added 'ELAPSED'
commit 9348d3b008
. Feb, 2022 - added 'STARTED'
commit 7647e96b0a
Signed-off-by: Jim Warner <james.warner@comcast.net>
When the 'STARTED' field was added, in the message for
the commit referenced below, I explained why 'ELAPSED'
shouldn't be implemented though it might be preferred.
Well, after climbing out of my box to do a little more
thinking, I came up with the way to add that 'ELAPSED'
field while avoiding the possible performance penalty.
Just do not show what would change with every refresh!
If we do not show the seconds portion of a scaled tics
amount then the problem goes away. And this comes with
an additional benefit. The HH,MM (hours,minutes) style
then is readily compared with that system uptime shown
as HH:MM. The only difference is just the comma/colon.
[ assuming the top uptime/load average toggle was on ]
Reference(s):
. introduced 'start time' field
commit 7647e96b0a
Signed-off-by: Jim Warner <james.warner@comcast.net>
When the 'STARTED' field was added, the width was made
the same as the 'TIME+' field. Thus, a full time could
be shown (which then included hundredths of a second).
That kind of granularity is totally unnecessary. After
all, this column is potentially confusing enough since
it is so counterintuitive. So, this commit will reduce
the width of the field with some help from scale_tics.
Henceforth it will not include those ol' centiseconds.
[ along the way let's expand the man document with a ]
[ a remainder about content representation & scaling ]
Reference(s):
. introduced 'start time' field
commit 7647e96b0a
Signed-off-by: Jim Warner <james.warner@comcast.net>