Commit Graph

2674 Commits

Author SHA1 Message Date
Nathan Scott
c144bf9ae5 Add changelog entries for pending htop-3.2.0 release, update version 2022-04-29 18:03:53 +10:00
Daniel Lange
ae518e20b7 Merge branch 'main' of thesamesam/htop 2022-04-26 13:56:40 +02:00
Daniel Lange
cdf3f3c50b Remove stray fprintf left from testing (introduced in 7039abe) 2022-04-26 13:35:35 +02:00
Benny Baumann
1f2f4fe891 Assume process just started when kproc->ki_start returns garbage 2022-04-21 08:56:56 +02:00
Benny Baumann
ec809b7f71 Avoid extremely large year values when printing time 2022-04-21 08:56:56 +02:00
Benny Baumann
b83ce85d89 Force elapsed time display to zero if process seems started in the future 2022-04-21 08:56:56 +02:00
Explorer09
ee1bf2f917 Process: Fix PID & UID column widths off-by-one error
If the max PID or UID value for a platform is exactly a power of ten
(10000, 100000, etc.) the column widths of PID and UID would be 1 char
less than the correct number of digits. This is caused by the wrong
rounding function (ceil(x)); change to the correct one (trunc(x) + 1).

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
2022-04-18 12:30:40 +02:00
ahsmha
afc4a9d657 README: Add macOS build dependency install command 2022-04-14 20:28:11 +02:00
Daniel Lange
3f3691886a Merge branch 'allow-multiple-filters-and-search-strings' into main
Closes #961
2022-04-14 16:45:29 +02:00
Daniel Lange
99aa906bc5 Merge branch 'improve-filter-label' into main 2022-04-14 16:44:51 +02:00
Daniel Lange
df955c8991 Make CLANG happy (-Wembedded-directive) 2022-04-07 12:33:22 +02:00
Daniel Lange
6a7b3fdc7d Do not show help for -M / --no-mouse if HAVE_GETMOUSE is undefined 2022-04-07 11:52:22 +02:00
hwangcc23
72c56691ec Fix a compile warning: comparison of unsigned enum expression < 0 is always false
Get this warning when compiling Settings.c on the Mac OS X with clang-800.0.42.1.
Settings.c:447:28: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
         if (this->hLayout < 0 || this->hLayout >= LAST_HEADER_LAYOUT)
             ~~~~~~~~~~~~~ ^ ~

This patch fixes the problem.
2022-04-05 09:23:03 +02:00
Fabrice Fontaine
4ccad46045 configure.ac: fix static build with hwloc
Retrieve hwloc dependencies through pkg-config to avoid the following
static build failure:

checking for hwloc_get_proc_cpubind in -lhwloc... no
configure: error: can not find required library libhwloc

This build failure is raised because without pkg-config, hwloc
dependencies such as libxml2 are not retrieved:

configure:8999: checking for hwloc_get_proc_cpubind in -lhwloc
configure:9022: /home/autobuild/autobuild/instance-0/output-1/host/bin/powerpc-buildroot-linux-uclibc-gcc -o conftest -D_GNU_SOURCE -I/home/autobuild/autobuild/instance-0/output-1/host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/../../usr/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Og -g0  -static -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -static conftest.c -lhwloc  -llzma -L/home/autobuild/autobuild/instance-0/output-1/host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/../../usr/lib -lncurses -lm   >&5
/home/autobuild/autobuild/instance-0/output-1/host/lib/gcc/powerpc-buildroot-linux-uclibc/10.3.0/../../../../powerpc-buildroot-linux-uclibc/bin/ld: /home/autobuild/autobuild/instance-0/output-1/host/powerpc-buildroot-linux-uclibc/sysroot/usr/bin/../../usr/lib/libhwloc.a(topology-xml-libxml.o): in function `hwloc_libxml_free_buffer':
topology-xml-libxml.c:(.text+0x6a): undefined reference to `xmlFree'

Fixes:
 - http://autobuild.buildroot.org/results/5d815ec08c580005a863df6ac9ac29deff7d4128

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2022-04-03 12:59:30 +02:00
Daniel Lange
7039abe109 Guess lxc or docker from /proc/1/mounts
At the moment this is used to make the memory meter report sane values even
if the host has ZFS and that leaks through into a containerized environment

Fixes #863

Includes a clever check for magic PROC_PID_INIT_INO in /proc/self/ns/pid thanks to Pavel Snajdr (snajpa)
2022-04-02 14:02:06 +02:00
Daniel Lange
2b7504b522 Merge branch 'full_meter' of cgzones/htop into main
Closes #786
2022-04-02 12:45:07 +02:00
Daniel Lange
8b927ba596 Merge branch 'main' (Linux: fix crash in LXD, fixes #965) of er-azh/htop into main 2022-04-02 12:38:00 +02:00
Daniel Lange
0ffd772d28 Fix header layout and meters reset if a header column is empty
Closes #880
Patch from BenBE and cgzones
2022-04-02 12:30:30 +02:00
er-azh
64fb7181ee
use xCalloc for allocating cpuData 2022-03-27 12:23:56 +04:30
er-azh
ba4c67942c
Linux: allocate cpuData before reading cpu count. 2022-03-26 17:27:36 +04:30
er-azh
3f0c172a60
Linux: fix crash in LXD 2022-03-26 15:48:12 +04:30
Daniel Lange
7c43e02591 Improve String_contains_i to allow for multiple terms
This enables:
* Multiple filters in the main panel and strace etc. views
* Multiple search terms

The search terms are separated by "|" and are still fixed strings
matched case-insensitive.

Added a multi flag at request of BenBE.
2022-03-25 17:19:59 +01:00
Daniel Lange
c6f946edd2 Improve MainPanel Label on active inc filter (Filter <-> FILTER) 2022-03-25 14:51:14 +01:00
HeshamTB
a2ca7583a9 README: Add Archlinux build dependency install command
Signed-off-by: HeshamTB <hishaminv@gmail.com>
2022-03-24 15:49:13 +01:00
Daniel Lange
469ae7a0bd Make sure License is correctly specified as GNU GPLv2+ in some more file headers 2022-03-14 07:33:40 +01:00
Benny Baumann
c4239335b9 Skip system slice name
This shortens paths like /system.slice/system-postgres.slice/postgres@12-main.service to /[S]/postgres@12-main.
Without this some cgroup names for getty processes explode in length.
2022-03-06 19:56:25 +01:00
Benny Baumann
23b56193d7 Reduce column width spam by snapd 2022-03-06 19:56:25 +01:00
Benny Baumann
edf319e53d Auto-size (normalized) CPU usage columns 2022-03-06 19:56:25 +01:00
Christian Göttsche
b6c0667eae Linux: dynamically adjust column width of CGROUP C(ompressed)CGROUP 2022-03-06 19:56:25 +01:00
Christian Göttsche
3ba695293c Linux: dynamically adjust the SECATTR column width
SELinux contexts can be quite long; adjust the column width dynamically
at each cycle to the longest value.

Also with the recent addition of multiple screens, over-long columns can
be moved into their own screen.
2022-03-06 19:56:25 +01:00
Kumar
6133cac721 Process: Handle rounding ambiguity between 99.9 and 100.0
Depending upon default behavior of the compiler and floating-point
environment, compiler could round down the value between "99.9" and
"100.0" to "99.0", instead of rounding it to the nearest value, "100.0".

Note: The floating-point environment access and modification is only
meaningful when "#pragma STD FENV_ACCESS" is set to "ON"[1]. Otherwise
implementation is free to assume that floating-point control modes are
always the default. So it would be a good idea to address the rounding
ambiguity between "99.9" and "100.0" to become compiler agnostic.

[1]: https://en.cppreference.com/w/c/numeric/fenv

Credits: @Explorer09, thanks for the suggestion.
2022-02-19 12:21:26 +01:00
Kumar
da653f8148 Process: Show only integer value when CPU% more than 99.9%
When we run a process which utilizes CPU between 100.0% and 999.9%, htop
shows an unnecessary decimal character at the end of the value. For
example, '100.x' and '247.x' become '100.' and '247.' respectively.

When CPU utilization is less than and equal to '99.9%', show the result
with single digit precision and if result is less than four characters,
pad it with the blank space. When CPU utilization is greater than
'99.9%', show only integral part of the result and if it's less than
four characters, pad it with the blank space.

Closes: #946
2022-02-19 12:21:26 +01:00
Charlie Vieth
d35db47c9a darwin: lazily set process TTY name
Fetching the TTY name of a process is extremely expensive on darwin and
the call to devname accounts for 95% of htop's CPU usage when there is
high process turnover (this is mostly due to devname calling lstat,
which is incredibly slow). This can make htop unresponsive.

To mitigate this only set the process TTY name if the it is being
actively displayed (PROCESS_FLAG_TTY), which by default it is not
on darwin.
2022-02-18 09:07:41 +01:00
Denis Lisov
978a7c894f ProcessList_buildTreeBranch: drop extra assert
It essentially only checks Vector_add, and there's already an assert for
that in the vector code.
2022-02-13 19:50:16 +01:00
Denis Lisov
79a6f6cb5b ProcessList_buildTree: skip hashtable if known root
Don't waste time looking up the parent if the current process is already
known to be a root process.
2022-02-13 19:50:16 +01:00
Denis Lisov
deb05fe7c2 ProcessList: delay tree rebuild until panel rebuild 2022-02-13 19:50:16 +01:00
Denis Lisov
82d34deaf1 ProcessList: cleanup the tree set sorting remains
They're no longer needed as rebuilding the tree from scratch is just as
fast.
2022-02-13 19:50:16 +01:00
Denis Lisov
fa3e0d06c2 ProcessList_buildTree: produce sorted tree
ProcessList_buildTree does not need any particular sort order for
children of the same process or roots. Switching these to the sort order
configured by the user produces sorted tree automatically, making repeat
sort unnecessary.
2022-02-13 19:50:16 +01:00
Denis Lisov
82dce5cf8e ProcessList_buildTree: sort by parent for fast search
ProcessList_buildTreeBranch used to search for children with a linear
scan of the process table, which made tree build time quadratic in
process count. Pre-sorting the list by parent PID (if known) makes it
possible to select the correct slice by bisection much faster.
2022-02-13 19:50:16 +01:00
Denis Lisov
8d987864e4 ProcessList_buildTree: drop sort direction checking
This is only a partial check that does not take into account the sort
field used and is overridden later anyway.
2022-02-13 19:50:16 +01:00
Denis Lisov
58b42e4cac ProcessList: introduce displayList
Separate `processes` (the vector owning the processes, sorted in
whatever order is needed right now internally) and `displayList` (a
vector referencing the processes in the same order they're to be
displayed).
2022-02-13 19:50:16 +01:00
Denis Lisov
2477a5a018 ProcessList_buildTree: handle every process once
Special-casing hidden processes does not serve any obvious purpose and
depends on the move from processes to processes2 which will be removed
in a later commit.
2022-02-13 19:50:16 +01:00
Denis Lisov
1a403eb7eb ProcessList_buildTree: lookup parent via hashtable
While this change does not significantly affect performance, it removes
the internal requirement to have the process list sorted by PID.
2022-02-13 19:50:16 +01:00
Denis Lisov
a3a7958721 ProcessList: sort before panel rebuild if needed 2022-02-13 19:50:16 +01:00
Daniel Lange
4aeb146ce8 Remove duplicate sections on COMM and EXE
Closes #934

Thank you, Narendran Gopalakrishnan (gnarendran)!
2022-02-13 17:22:39 +01:00
Jan Kończak
8c99683b04 Fix custom thread name display issue
Fixes #877
2022-02-13 16:59:29 +01:00
Benny Baumann
265a7b8a50 Fix division by zero when calculating IO rates
Fixes #935
2022-02-03 17:48:18 +01:00
Sam James
939685dff9
build: use AC_CANONICAL_HOST, not AC_CANONICAL_TARGET
htop is a program which will be run on CHOST after cross-compilation;
CTARGET is only for a small number of cases where a program itself outputs
code (so you might cross-compile a compiler which spits out code for a third
architecture/platform).

We want to use AC_CANONICAL_HOST to check CHOST for the platform currently
being used to build htop.

The confusion around this issue was compounded by a mistake in autoconf-archive
which has since been fixed (AX_PTHREAD pulled it in incorrectly).

See: https://github.com/libstatgrab/libstatgrab/pull/131
See: https://github.com/fenrus75/powertop/pull/90#discussion_r705803725
Signed-off-by: Sam James <sam@gentoo.org>
2022-01-22 03:57:14 +00:00
Jessica Clarke
3e1a27a981 freebsd/dragonfly: Stop aligning equals signs in PLATFORM_PROCESS_FIELDS
ProcessField doesn't do this, nor does any other OS, and it just makes
it more annoying to add a new field.
2022-01-18 07:23:36 +01:00
Jessica Clarke
9512fd7930 FreeBSD: Add support for showing process emulation
This displays the same output as ps's -o emul, which is the system call
emulation environment, or ABI, in use. This will typically be FreeBSD
ELF32 or ELF64, but can also be Linux ELF32 or Linux ELF64 when running
Linux binaries under FreeBSD's Linuxulator binary compatibility layer.
The column width of 16 is chosen to match KI_EMULNAMELEN's value of 16,
most of which is normally used up as FreeBSD ELF32/64 is 13 characters.
2022-01-16 17:21:18 +01:00