Christian Göttsche 68460b25e3 Reset the signal handlers at program exit
The signal handler will access the Settings struct, which gets freed at
normal program finalization.

When using leak sanitizers with ASAN_OPTIONS=abort_on_error=1, which
runs after program termination, any leak causes SIGABRT to be raised,
calling the crash handler, which will derefernce the freed Settings.

    ==44741==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d000000080 at pc 0x0000005680df bp 0x7fffe335e960 sp 0x7fffe335e958
    READ of size 8 at 0x60d000000080 thread T0
        #0 0x5680de in Settings_write /home/christian/Coding/workspaces/htop/Settings.c:329:26
        #1 0x4f77b7 in CRT_handleSIGSEGV /home/christian/Coding/workspaces/htop/CRT.c:1020:4
        #2 0x7f8a1120c13f  (/lib/x86_64-linux-gnu/libpthread.so.0+0x1413f)
        #3 0x7f8a11042ce0 in __libc_signal_restore_set signal/../sysdeps/unix/sysv/linux/internal-signals.h:86:3
        #4 0x7f8a11042ce0 in raise signal/../sysdeps/unix/sysv/linux/raise.c:48:3
        #5 0x7f8a1102c536 in abort stdlib/abort.c:79:7
        #6 0x4c3db6 in __sanitizer::Abort() (/home/christian/Coding/workspaces/htop/htop+0x4c3db6)
        #7 0x4c2090 in __sanitizer::Die() (/home/christian/Coding/workspaces/htop/htop+0x4c2090)
        #8 0x4d0a17 in __lsan::HandleLeaks() (/home/christian/Coding/workspaces/htop/htop+0x4d0a17)
        #9 0x4cd950 in __lsan::DoLeakCheck() (/home/christian/Coding/workspaces/htop/htop+0x4cd950)
        #10 0x7f8a110454d6 in __run_exit_handlers stdlib/exit.c:108:8
        #11 0x7f8a11045679 in exit stdlib/exit.c:139:3
        #12 0x7f8a1102dd10 in __libc_start_main csu/../csu/libc-start.c:342:3
        #13 0x428a19 in _start (/home/christian/Coding/workspaces/htop/htop+0x428a19)

    0x60d000000080 is located 64 bytes inside of 144-byte region [0x60d000000040,0x60d0000000d0)
    freed by thread T0 here:
        #0 0x4a4f72 in free (/home/christian/Coding/workspaces/htop/htop+0x4a4f72)
        #1 0x566693 in Settings_delete /home/christian/Coding/workspaces/htop/Settings.c:32:4
        #2 0x4ede10 in CommandLine_run /home/christian/Coding/workspaces/htop/CommandLine.c:393:4
        #3 0x4d6f32 in main /home/christian/Coding/workspaces/htop/htop.c:15:11
        #4 0x7f8a1102dd09 in __libc_start_main csu/../csu/libc-start.c:308:16

    previously allocated by thread T0 here:
        #0 0x4a5372 in __interceptor_calloc (/home/christian/Coding/workspaces/htop/htop+0x4a5372)
        #1 0x57f61a in xCalloc /home/christian/Coding/workspaces/htop/XUtils.c:55:17
        #2 0x5688a6 in Settings_new /home/christian/Coding/workspaces/htop/Settings.c:392:21
        #3 0x4ecb57 in CommandLine_run /home/christian/Coding/workspaces/htop/CommandLine.c:303:25
        #4 0x4d6f32 in main /home/christian/Coding/workspaces/htop/htop.c:15:11
        #5 0x7f8a1102dd09 in __libc_start_main csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: heap-use-after-free /home/christian/Coding/workspaces/htop/Settings.c:329:26 in Settings_write
2021-08-16 08:05:07 +02:00
2021-08-08 15:10:58 +02:00
2021-07-15 06:57:24 +02:00
2020-12-11 20:57:19 +01:00
2021-02-05 14:12:49 +01:00
2021-07-18 07:47:09 +02:00
2021-05-10 18:40:53 +02:00
2020-12-05 11:07:32 +01:00
2021-03-04 23:57:45 +01:00
2021-05-10 18:40:53 +02:00
2021-06-18 07:52:44 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-04-14 17:29:56 +02:00
2020-08-21 10:37:33 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2020-12-20 17:01:50 +01:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2020-12-21 22:34:50 +01:00
2021-07-15 06:57:24 +02:00
2021-05-10 18:40:53 +02:00
2021-07-18 07:44:02 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-07-15 06:57:24 +02:00
2021-07-15 06:57:24 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2020-08-21 10:37:33 +02:00
2021-03-12 16:38:36 +01:00
2021-07-15 06:57:24 +02:00
2020-11-19 23:51:50 +01:00
2021-07-18 07:50:48 +02:00
2014-02-03 09:11:39 -02:00
2021-05-10 18:40:53 +02:00
2021-05-10 17:48:05 +02:00
2021-01-04 23:12:43 +01:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-08-14 11:16:03 +02:00
2021-05-10 18:40:53 +02:00
2020-08-21 10:37:33 +02:00
2021-02-13 14:04:15 +01:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-05-10 18:40:53 +02:00
2021-07-15 06:57:24 +02:00

htop

CI Coverity Scan Build Status Mailing List IRC #htop Github Release

Screenshot of htop

Introduction

htop is a cross-platform interactive process viewer.

htop allows scrolling the list of processes vertically and horizontally to see their full command lines and related information like memory and CPU consumption.

The information displayed is configurable through a graphical setup and can be sorted and filtered interactively.

Tasks related to processes (e.g. killing and renicing) can be done without entering their PIDs.

Running htop requires ncurses libraries (typically named libncursesw*).

For more information and details on how to contribute to htop visit htop.dev.

Build instructions

Prerequisite

List of build-time dependencies:

  • build-essential standard GNU autotools-based
  • autoconf
  • autotools
  • ncurses

Note about ncurses:

htop requires ncurses 6.0. Be aware the appropriate package is sometimes still called libncurses5 (on Debian/Ubuntu). Also ncurses usually comes in two flavours:

  • With Unicode support.
  • Without Unicode support.

This is also something that is reflected in the package name on Debian/Ubuntu (via the additional 'w' - 'w'ide character support).

List of additional build-time dependencies (based on feature flags):

  • sensors
  • hwloc
  • libcap

Compiling htop requires the header files for ncurses . Install these and other required packages for C development from your package manager.

Debian/Ubuntu

sudo apt install libncursesw5-dev autotools-dev autoconf

Fedora/RHEL

sudo dnf install ncurses-devel automake autoconf

Compiling from source:

To compile from sources downloaded from the Git repository (git clone or downloads from Github releases), then run:

./autogen.sh && ./configure && make

By default make install will install into /usr/local, for changing the path use ./configure --prefix=/some/path.

Install

To install on the local system run make install. By default make install installs into /usr/local. To change this path use ./configure --prefix=/some/path.

Build Options

htop has several build-time options to enable/disable additional features.

Generic

  • --enable-unicode: enable Unicode support dependency: libncursesw default: yes
  • --enable-pcp: enable Performance Co-Pilot support via a new pcp-htop utility dependency: libpcp default: no
  • --enable-affinity: enable sched_setaffinity(2) and sched_getaffinity(2) for affinity support; conflicts with hwloc default: check
  • --enable-hwloc: enable hwloc support for CPU affinity; disables affinity support dependency: libhwloc default: no
  • --enable-static: build a static htop binary; hwloc and delay accounting are not supported default: no
  • --enable-debug: Enable asserts and internal sanity checks; implies a performance penalty default: no

Linux

  • --enable-sensors: enable libsensors(3) support for reading temperature data dependencies: libsensors-dev(build-time), at runtime libsensors is loaded via dlopen(3) if available default: check
  • --enable-capabilities: enable Linux capabilities support dependency: libcap default: check
  • --with-proc: location of a Linux-compatible proc filesystem default: /proc
  • --enable-openvz: enable OpenVZ support default: no
  • --enable-vserver: enable VServer support default: no
  • --enable-ancient-vserver: enable ancient VServer support (implies --enable-vserver) default: no
  • --enable-delayacct: enable Linux delay accounting support dependencies: pkg-config(build-time), libnl-3 and libnl-genl-3 default: check

Runtime dependencies:

htop has a set of fixed minimum runtime dependencies, which is kept as minimal as possible:

  • ncurses libraries for terminal handling (wide character support).

Runtime optional dependencies:

htop has a set of fixed optional dependencies, depending on build/configure option used:

  • libdl, if not building static and support for some of the optional libraries is enabled, is always required when support for to optionally load dependencies (i.e. libsensors, systemd) is present.
  • libcap, user-space interfaces to the POSIX 1003.1e, is always required when --enable-capabilities was used to configure htop.
  • libsensors, readout of temperatures and CPU speeds, is optional even when --enable-sensors was used to configure htop.
  • systemd is optional when --enable-static was not used to configure htop (Linux only). If building statically and libsystemd is not found by configure support for the SystemD meter is disabled entirely.

htop checks for the availability of the actual runtime lib as htop runs.

BSD On most *BSD systems you also have kvm as a static requirement to read all the kernel information.

More information on required and optional dependencies can be found in configure.ac.

Usage

See the manual page (man htop) or the on-line help ('F1' or 'h' inside htop) for a list of supported key commands.

Support

If you have trouble running htop please consult your Operating System / Linux distribution documentation for getting support and filing bugs.

Bugs, development feedback

We have a development mailing list. Feel free to subscribe for release announcements or asking questions on the development of htop.

You can also join our IRC channel #htop on Libera.Chat and talk to the developers there.

If you have found an issue with the source of htop, please check whether this has already been reported in our Github issue tracker. If not, please file a new issue describing the problem you have found, the location in the source code you are referring to and a possible fix.

History

htop was invented, developed and maintained by Hisham Muhammad from 2004 to 2019. His legacy repository has been archived to preserve the history.

In 2020 a team took over the development amicably and continues to maintain htop collaboratively.

License

GNU General Public License, version 2 (GPL-2.0)

Description
htop - an interactive process viewer
Readme 6 MiB
Languages
C 93%
Roff 2.3%
M4 2.3%
Lua 1.5%
Makefile 0.8%