Commit Graph

2314 Commits

Author SHA1 Message Date
Nipunn Koorapati
3549f49df0 Supporting bright colors with ncurses 2020-12-22 13:53:04 +11:00
Nipunn Koorapati
a23c941d8b Support simple 8 bit ansi escape sequences
See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
Support standard and high intensity colors. The default
ncurses colors ARE the high intensity colors - represented
via an 8 bit ansi escape sequence here.
2020-12-22 13:53:00 +11:00
Craig Small
6285bdd3b5 Merge branch 'nipunn1313/procps-watch_colors'
References:
 procps-ng/procps!106
2020-12-22 13:48:15 +11:00
Nipunn Koorapati
ffa556633f Spaces to tabs 2020-12-22 13:44:54 +11:00
Nipunn Koorapati
a3a5db1311 Add comments and limit to standard colors 2020-12-22 13:43:30 +11:00
Nipunn Koorapati
8d0928f072 bugfix - increment endpointer when parsing color_escape_sequence 2020-12-22 13:43:30 +11:00
Nipunn Koorapati
486a3e30e1 Support simple 8 bit ansi escape sequences
See https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
Support standard and high intensity colors. The default
ncurses colors ARE the high intensity colors - represented
via an 8 bit ansi escape sequence here.
2020-12-22 13:43:25 +11:00
Craig Small
e2470edc8c Merge branch 'antonblanchard/procps-proc-stat-buffer'
References:
 procps-ng/procps!105
2020-12-22 13:18:58 +11:00
Anton Blanchard
1b9ea61116 Increase BUFFSIZE to handle very large /proc/stat files
We read /proc/stat using a statically sized buffer. This was increased
to 64kB in 2005 via commit 777fcd3cf1 "/proc/stat for 1024 CPUs".

Unfortunately in 2020, 1024 CPUs is not enough for anyone. I have a
large machine where /proc/stat is 74kB, and vmstat gives incorrect
output.

Double the buffer to 128kB in the confidence that 2048 CPUs is actually
enough for anyone.

Signed-off-by: Anton Blanchard <anton@ozlabs.org>
2020-12-22 13:18:44 +11:00
Craig Small
4a54ae97a0 testsuite: Add pwait tests
They're pretty simple tests but its something.

References:
  commit 09327c2b77
2020-12-22 12:25:44 +11:00
Craig Small
980983db74 Merge branch 'alxu/procps-pwait'
New command, pwait! Waits for another process to finish just like
pgrep finds or pkill kills another process.

References:
 procps-ng/procps!97

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2020-12-22 12:16:09 +11:00
Alex Xu (Hello71)
09327c2b77 pgrep: add pwait 2020-12-22 12:09:16 +11:00
Craig Small
03fac47bd2 Merge branch 'nipunn1313/procps-spaces_to_tabs'
References:
 procps-ng/procps!108
2020-12-22 11:55:10 +11:00
Nipunn Koorapati
5d155068ce Convert spaces to tabs in watch.c 2020-12-22 11:54:52 +11:00
Craig Small
9c4ad4c419 Merge branch 'nipunn1313/procps-configure_ncurses'
Macs have the wide stuff in the ncurses (not ncursesw) library.

References:
 procps-ng/procps!110
 procps-ng/procps#47
2020-12-22 11:45:47 +11:00
Nipunn Koorapati
e0f47aab1c watch: Support wide char ncurses on mac with enable-watch8bit
Fixes #47
2020-12-22 11:45:20 +11:00
Samanta Navarro
b0c8e3408b misc: fix typos in manual pages
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
2020-12-22 00:37:29 +00:00
Jan Rybar
584c65ba37 pkill manpage to document '-e' option 2020-12-22 00:30:50 +00:00
Jan Rybar
bf6c096dbd pidof: new option to show cmdline-less PIDs (kernel workers), empty input fixed 2020-12-22 00:14:41 +00:00
Craig Small
a04ea67d6f Merge branch 'brenns10/procps-master'
References:
 procps-ng/procps!119
2020-12-22 11:08:52 +11:00
Stephen Brennan
31343570e1 Set TZ to avoid repeated stat("/etc/localtime")
With glibc, each time the strftime() function is used (twice per process
in a typical ps -fe run), a stat("/etc/localtime") system call is used
to determine the timezone. Not only does this add extra system call
overhead, but when multiple ps processes are trying to access this
file (or multiple glibc programs using strftime) in parallel, this can
trigger significant lock contention within the OS kernel.

Since ps is not intended to run for long periods of time as a
daemon (during which the system timezone could be altered and PS might
reasonably be expected to adapt its output), there is no benefit to
repeatedly doing this stat(). To stop this behavior, explicitly set the
TZ variable to its default value (:/etc/localtime) whenever it is unset.
glibc will then cache the stat() result.
2020-12-22 11:08:36 +11:00
Craig Small
930dad118e Merge branch 'ratijas/procps-man-watch'
References:
 procps-ng/procps!121
2020-12-22 11:03:57 +11:00
ivan tkachenko
bfaa431052 docs: Consistent style across watch.1 2020-12-22 11:02:58 +11:00
Craig Small
fc93e2919d misc: Document sysctl change bug
While sysctl did change the order of /run and /etc to match
systemd in the referenced commit, the Debian bug report that
brought it to light was not documented.

References:
 commit 24a1574f0a
 https://bugs.debian.org/950788
2020-12-22 10:55:18 +11:00
Jim Warner
2a5b8658d2 top: a small safeguard added to the ATEOJ_RPTHSH logic
If a hash results report was output (via ATEOJ_RPTHSH)
a portion is devoted to occupied table entries ordered
by depth. There is a possibility that some depths will
not be found among existing occupied table entries and
to avoid any confusion probably should not be printed.

[ to illustrate the potential for confusion prior to ]
[ this patch, force a very small table size (like 8) ]
[ and then arrange to trigger the end-of-job report. ]

So this patch ensures only 'in use' entries are shown.

[ admittedly, all of the remaining logic in the loop ]
[ could/should be subordinate to this new 'if' test, ]
[ but we will keep the change to a minimum. besides, ]
[ there's no harm subtracting/adding a zero numdepth ]
[ especially since the chance of a zero is very low. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-10-24 18:29:13 +11:00
Craig Small
cb13448179 free,slabtop,uptime: complain about extra ops
free, slabtop and uptime would happily take extra command line
arguments and doing nothing about them. The programs now check
optind after option processing and will give you usage screen
if there is anything extra.

References:
 procps-ng/procps#181
2020-10-19 22:36:06 +11:00
Craig Small
d748966e39 watch: Add no linewrap option
For long lines from a process, watch would wrap them around to the
next. While this default option has it uses, sometimes you want to
just cut those long lines down.

watch has a -w flag which will truncate the lines to the number
of columns. A few simple lines to do this new trick.

I think I caught all the ANSI state correctly but there might be
a chance it bleeds to the next row.

References:
 procps-ng/procps#182
2020-10-19 22:03:44 +11:00
Jim Warner
d10c8fccc9 top: just a small tweak to that history hash algorithm
This patch just raises the size of the hash table used
to calculate elapsed task stuff. The net result should
be less need for 'chaining' under pid hash collisions.

[ the hash scheme is intentionally kept as primitive ]
[ and, therefore, as fast as possible. it employs an ]
[ 'and' approach versus a 'mod' operation since both ]
[ yield similar distribution but the former approach ]
[ was 4 fewer cpu instructions in terms of overhead. ]

[ additionally, for hash collisions, 'chaining' uses ]
[ an array index rather than the usual pointer since ]
[ the HST_t guys may move when they are reallocated. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-10-11 17:51:49 +11:00
Craig Small
3e1c00d051 ps: Match on truncated 16 char for -C
The referenced commit the comm length was increased from 16 to 64
characters to handle the larger command names for things like kernel
threads.

However most user processes are limited to 15 characters which means
if you try something like ps -C myprogramisbiggerthansixteen this would
fail to match because /proc/<PID>/comm would only be myprogramisbigg

ps now checks the comm length and if it is 15 and if the given match
is 15 or more, it will only match the first 15 characters.

This is also how killall has worked for about a year.

Thanks to Jean Delvare <jdelvare@suse.de> for the note.

References:
 commit 14005a371e
 commit psmisc/psmisc@1188315cd0

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2020-09-24 22:01:22 +10:00
Jim Warner
6e1715d9eb top: fix additional SEGVs if no tasks were displayable
This patch is an outgrowth of that commit shown below.

Many additional potential segmentation faults might be
encountered if interactive commands are opened up to a
user when a '-p' switch has a single non-existent pid.

[ always the 'k', 'L', 'r', 'Y' keys & maybe 'v' too ]

So, this patch will restrict such a loser (oops, user)
to a reduced subset of normal commands until he/she/it
quits then restarts top with something to be displayed
or issues the '=' command overriding that '-p' switch.

Reference(s):
commit f57a0301e3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-09-16 14:27:31 +10:00
Jim Warner
f57a0301e3 top: fix potential SEGV when no tasks were displayable
This patch fixes a nearly decade old bug discovered by
Frederik Deweerdt. His merge request shown below would
be an adequate solution except for iterative overhead.

This alternate patch will represent substantially less
overhead for an admittedly extremely rare possibility.

Reference(s):
https://gitlab.com/procps-ng/procps/-/merge_requests/114

And-thanks-to: Frederik Deweerdt <fdeweerdt@fastly.com>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-09-13 10:28:50 +10:00
Jim Warner
7a19961fc2 top: update user/system cpu % graph content (man page)
What had been stated as the contents of the cpu graphs
was never really inclusive enough. Those recent newlib
tweaks highlighted the need for these man doc changes.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-09-13 10:28:50 +10:00
Jim Warner
5646506488 build-sys: updated autoscan for that configure.ac file
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-09-13 10:28:50 +10:00
Jim Warner
762249e8ec top: even more useless cosemetic stuff (only comments)
[ this is what happens when i've run out of bugs and ]
[ issues and am now left with way too much free time ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-09-13 10:28:50 +10:00
Jim Warner
072a850761 top: more useless cosemetic changes (chiefly comments)
All of these changes are self-explanatory, so I'll not
provide any more comments thus avoiding further shame.

[ everything's perfectly justified and right margins ]
[ are filled entirely, but of course it must be luck ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-09-13 10:28:50 +10:00
Jim Warner
e319650278 misc: eliminate a couple of miscellaneous gcc warnings
This commit just addresses those warnings shown below.

Reference(s):
proc/sysinfo.c: In function `getrunners':
proc/sysinfo.c:491:26: warning: `%s' directive writing up to 255 bytes into a region of size 26 [-Wformat-overflow=]
  491 |     sprintf(tbuf, "/proc/%s/stat", ent->d_name);
      |                          ^~

pgrep.c: In function `select_procs':
pgrep.c:591:11: warning: suggest explicit braces to avoid ambiguous `else' [-Wdangling-else]
  591 |   else if (opt_older)
      |           ^

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-29 18:58:33 +10:00
Jim Warner
71d49f168a top: for consistency, reposition a few man page macros
This patch just repositions some .PP macros so they'll
immediately precede the paragraphs to which they apply
rather than a comment line used as a visual separator.

[ ok we also update the document date to 'July 2020' ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-29 18:58:33 +10:00
Jim Warner
723f146b24 build-sys: suppress '-Wunused-result' with AM_CPPFLAGS
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-20 16:12:00 +10:00
Jim Warner
78053c85fc top: address several 'mandoc -Tlint' errors & warnings
This commit addresses the errors/warnings shown below.

Reference(s):
ERROR: skipping end of block that is not open: RE
WARNING: skipping paragraph macro: sp after PP
WARNING: skipping paragraph macro: PP empty

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-20 16:12:00 +10:00
Jim Warner
3e92b4c9ff top: make that 'cpu_prt' function a tad more efficient
This commit only eliminates two 'nop' instructions and
one 'jmp' instruction. However, it makes that C source
code look a little bit prettier than it looked before.

[ and yes, some unnecessary parenthesis were used to ]
[ force an alignment of some related lines. it costs ]
[ us nothing in extra code yet helps in readability. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-20 16:12:00 +10:00
Jim Warner
246c5fa812 top: make the 'cpu_tics' function a tad more efficient
This patch eliminates one variable which resulted in a
corresponding elimination of three 'mov' instructions.

[ that was 6 bytes per 'mov' for a total of 18 bytes ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-07-20 16:12:00 +10:00
Craig Small
9232625f0f Merge branch 'jrybar/procps-vmstat-watch-manpage-fix'
References:
 procps-ng/procps!103
2020-07-01 08:04:51 +10:00
Jan Rybar
354b5a56bf vmstat and watch manpage slight fixes
vmstat - align wording with proc manpage to clarify ambiguities  (rhbz#1796043)
watch - manpage presumes ntp tools are present by default (which they're not on rpm and deb distros, rhbz#1583669)
2020-06-30 10:54:58 +02:00
Jim Warner
63691d6734 top: raise the amount by which top's stat buffer grows
We won't go as far as the merge request shown below in
increasing buffer size, but we'll reduce substantially
total iterations while growing it to achieve one read.

[ and this seems in line with what was recently done ]
[ to accommodate the massively parallel environments ]
[ thru 2 abreast ('4') and combined cpus ('!') modes ]

Reference(s:
https://gitlab.com/procps-ng/procps/-/merge_requests/105

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-29 21:12:02 +10:00
Jim Warner
8ebdaf8bcf NEWS: updated for those recent utf-8 translation fixes
Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-29 21:12:02 +10:00
Jim Warner
c509d9bcbb top: provide for zero length character in utf8 support
This commit is prompted by the preceding change to the
library's escape.c module which, in turn, was prompted
by that issue shown below (with thanks to Konstantin).

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/176

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-23 19:05:03 +10:00
Jim Warner
bb1a79f2c8 library: correct that 'escape_str_utf8' guy's behavior
Thanks to Konstantin for discovering 2 problems in the
issue referenced below. That 15+ year old logic went a
little too far overboard wrestling with a utf8 string.

Henceforth, we will not treat 'x9b' as special. And we
also will handle a 'combining acute accent' correctly.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/176

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-23 19:05:03 +10:00
Jim Warner
e3249ebb97 top: some miscellaneous accumulated tweaks and cleanup
I've grown to hate that man document rendering when it
comes to hyphenation. So this patch will eliminate it.

And we'll also eliminate an unnecessary initialization
in that top program code concerned with combined cpus.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-23 19:05:03 +10:00
Craig Small
cc032cbd99 docs: some manpage fixes
Some editorial changes so the man pages follow the standards.

References:
 procps#173
2020-06-04 22:25:26 +10:00
Jim Warner
f0fb35b645 top: fix a minor startup flaw for the '2 abreast' mode
This ensures that a single '4' keystroke will reliably
toggle the new 2 abreast mode ON. Depending on whether
an older configuration file existed or whether top was
configured with '--disable-modern-top', keying the '4'
for a second time might otherwise have been necessary.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2020-06-04 20:16:21 +10:00