109 Commits

Author SHA1 Message Date
e785693ef9 Release 3.1.1 2021-10-14 23:42:05 +02:00
4cf74de1f1 Suppress reporting memory leaks originating from libdevstat
Based on https://cgit.freebsd.org/src/tree/lib/libdevstat/devstat.c
the following four functions call memory allocation functions:

- devstat_getdevs()
- devstat_selectdevs()
- devstat_buildmatch()
- get_devstat_kvm()
2021-10-14 23:25:19 +02:00
0a5890d332 Updates to the ChangeLog for 3.1.1 release 2021-10-13 17:03:35 +11:00
2128edfba2 Plug the memory leak for the Disk I/O meter
There are no functions in libdevstat to initialise or clean up memory. The simplest change is to mark the local variable info as static.
2021-10-12 09:09:00 +02:00
d1c833fe95 Merge branch 'revert-used-memory' 2021-10-12 17:47:03 +11:00
868b0b3574 Ensure consistent reporting of MemoryMeter used memory
Resolves #821
2021-10-12 17:46:44 +11:00
04871a2d04 Report hugepage memory as real and used memory (as before)
This is real, physical memory available for applications to
use.  We should not try to pretend otherwise; its confusing
for users and inconsistent with all other tools.
2021-10-12 17:46:16 +11:00
b7248f6cb8 Handle procExeDeleted & usesDeletedLib without mergedCommandline mode 2021-10-07 08:42:08 +02:00
74afca7bc1 Validate meter configuration before proceeding 2021-10-06 08:59:02 +02:00
2a13e15ad0 Properly release memory on partially read configuration 2021-10-06 08:59:02 +02:00
8ac8542b6e Handle interrupted sampling from within libpcp PDU transfers
This situation can arise if pcp-htop screen is resized right
at the same time sampling from pmcd(1) is happening.  Have a
couple more goes at it before giving up entirely; once there
is no data available though we cannot proceed into accessing
the sample result data structure (segv will result) so a new
short-circuit guard is added there also.
2021-10-05 15:53:18 +11:00
f75a8bc3a1 Memory leak on OpenBSD when querying full command line 2021-10-03 19:18:25 +02:00
d520199e62 Memory leak on NetBSD when querying full command line 2021-10-03 19:18:25 +02:00
9d8d87e1d5 Memory leak on DragonFlyBSD when querying full command line 2021-10-03 19:18:25 +02:00
57c1538887 Don't force allocation, as failure is handled 2021-10-03 19:18:25 +02:00
9eb52d5932 Release memory for cmdline when Process_updateCmdline() returns.
This closes a nasty memory leak. There is at least another leak looming somewhere when Disk I/O is shown in the header area. That could very well be an issue within libdevstat native to FreeBSD.
2021-10-03 19:18:11 +02:00
970885edc3 Linux: improve tryRead macro safety
Add an explicit else clause so a following else branch for a prior if
condition does not get mixed up.

Also force a trailing semicolon and thereby silence current
-Wextra-semi-stmt warnings.

Improve readability of the hwloc_bitmap_foreach_begin loop macro.
2021-10-01 18:36:35 +02:00
ae1816e563 Settings: use size_t for meter count in header
Header.c:150:26: error: implicit conversion loses integer precision: 'int' to 'uint8_t' (aka 'unsigned char') [-Werror,-Wimplicit-int-conversion]
          colSettings->len = len;
                           ~ ^~~
2021-10-01 18:36:35 +02:00
53732ab0bb Resolve -Wimplicit-int-conversion warnings
Panel.c:414:49: error: implicit conversion loses integer precision: 'int' to 'short' [-Werror,-Wimplicit-int-conversion]
      this->scrollH = MAXIMUM(this->selectedLen - this->w, 0);
                    ~         ~~~~~~~~~~~~~~~~~~^~~~~~~~~
./Macros.h:11:54: note: expanded from macro 'MAXIMUM'
#define MAXIMUM(a, b)                  ((a) > (b) ? (a) : (b))
                                                     ^

IncSet.c:159:38: error: implicit conversion loses integer precision: 'int' to 'char' [-Werror,-Wimplicit-int-conversion]
         mode->buffer[mode->index] = ch;
                                   ~ ^~

Panel.c:456:24: error: implicit conversion loses integer precision: 'int' to 'char' [-Werror,-Wimplicit-int-conversion]
         buffer[len] = ch;
                     ~ ^~
Panel.c:473:22: error: implicit conversion loses integer precision: 'int' to 'char' [-Werror,-Wimplicit-int-conversion]
         buffer[0] = ch;
                   ~ ^~
2021-10-01 18:36:35 +02:00
8932efece9 astyle: Add --pad-header option
Insert space padding between a header (e.g. 'if', 'for', 'while'...) and the
following paren. ex:

if(isFoo((a+2), b))
    bar(a, b);

becomes:

if (isFoo((a+2), b))
    bar(a, b);

Link: http://astyle.sourceforge.net/astyle.html#_pad-paren
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
2021-10-01 15:01:51 +02:00
d23627fda9 Adds a missing HAVE_GETMOUSE check.
Fixes builds failing with error
MainPanel.c:65:62: error: 'Settings {aka struct Settings_}' has no member named 'enableMouse'
    if (ch != ERR && (ch != KEY_MOUSE || this->state->settings->enableMouse))
2021-09-29 22:21:53 +02:00
4c846921a6 Improve configuration file version diagnostic formatting slightly 2021-09-27 15:13:01 +10:00
c5e789db1b Prepare changelog contents for the 3.1.1 bugfix release 2021-09-27 13:33:48 +10:00
eb94c4f9c9 Merge branch 'amomchilov-workaround-for-FB9546856' 2021-09-27 13:15:58 +10:00
8361c6c1ae Merge branch 'workaround-for-FB9546856' of https://github.com/amomchilov/htop into amomchilov-workaround-for-FB9546856 2021-09-27 13:15:50 +10:00
07f934ccfb Update the README to drop now redundant glibc version requirement 2021-09-27 13:14:23 +10:00
6f751d5929 Merge branch 'o_path' of https://github.com/cgzones/htop into cgzones-o_path 2021-09-27 13:13:13 +10:00
e26a2cf431 Workaround for Rosetta 2 on Darwin
rdar://FB9546856

https://openradar.appspot.com/radar?id=5055988478509056
2021-09-26 10:58:47 -04:00
d527bc9132 Refactor Platform_CompareKernelVersion API 2021-09-26 10:58:47 -04:00
dadcb87ad0 Extract Darwin "PlatformHelpers" 2021-09-26 10:58:47 -04:00
754c0d6bb9 Linux: always compute procExeDeleted if already set
A process, whose executable has been replaced and thus marked by htop,
can be re-executed with the replaced executable, with the same PID, in
two ways: the Linux feature checkpoint/restore or re-execution of PID 1.
The actual check is just a string comparison, like the dropped
condition, leading to (almost) no computation overhead.
2021-09-24 22:03:16 +02:00
9f4a4faab9 Merge branch 'license' of cgzones/htop 2021-09-24 21:25:00 +02:00
a710deeaa7 Linux: define O_PATH if not defined
Defining O_PATH if not defined by <fcntl.h> does not really add any
maintenance cost and might improve some portability.

Related: #804
2021-09-24 20:31:48 +02:00
466d6f99e2 Update remaining license headers to explicitly say GPLv2+
Also change ReadMe badge.
2021-09-24 20:28:26 +02:00
1601931bbf Merge branch 'fasterit-clarify-license' 2021-09-24 11:59:41 +10:00
41f9c0ab77 Merge branch 'clarify-license' of https://github.com/fasterit/htop into fasterit-clarify-license 2021-09-24 11:59:32 +10:00
e28d022716 Merge branch 'automake-compat' 2021-09-24 11:59:09 +10:00
d5ac75a5c7 Merge branch 'fasterit-fix-mouse-wheel' 2021-09-24 11:58:03 +10:00
2ba7d5ff36 Merge branch 'fix-mouse-wheel' of https://github.com/fasterit/htop into fasterit-fix-mouse-wheel 2021-09-24 11:57:52 +10:00
3d99c306b9 Document minimum versions for glibc and libcap. Thank you to James Brown (Roguelazer).
Closes #804
2021-09-23 18:10:51 +02:00
3d3474b3fc Adjust Makefile.am macro definitions for older automake versions
Fixes: #803
2021-09-23 10:06:38 +10:00
94ad111391 Update license headers to explicitly say GPLv2+ 2021-09-22 14:28:19 +02:00
976fa3b121 Make the "Released under the GNU GPLv2+. See 'man' page for more info." from ScreenManager.c valid 2021-09-22 14:23:49 +02:00
61227793de Clarify licensing
htop has been licensed as GPLv2 but there was inconsistency regarding the
option to choose "any later version" as granted by the license.

This commit clarifies the htop dev team is fine with that choice.
2021-09-22 14:23:38 +02:00
e6ded48d1a Update version to 3.1.1-dev 2021-09-22 11:49:25 +02:00
87c992739b Fix mouse wheel collision with autogroups nice adjustment
Fixes #805
2021-09-22 09:00:31 +02:00
29e1fcfa05 Use libunwind for printing backtrace 2021-09-21 09:06:30 +02:00
29983ff83a Release 3.1.0 2021-09-21 16:30:46 +10:00
36b7f57200 Some minor editorial changes to the readme 2021-09-20 16:48:39 +02:00
c5fe142256 Bump to rc3, likely final release commits for 3.1.0 2021-09-20 16:34:39 +10:00
691b7dd5af Merge branch 'cgzones-readme' 2021-09-20 16:31:31 +10:00
ad0f9c58bf Merge branch 'readme' of https://github.com/cgzones/htop into cgzones-readme 2021-09-20 16:31:24 +10:00
a8d0f2a7fe Merge branch 'cgzones-multicolumn' 2021-09-20 16:30:18 +10:00
e6596cbd69 Merge branch 'multicolumn' of https://github.com/cgzones/htop into cgzones-multicolumn 2021-09-20 16:29:44 +10:00
40c9f89971 Merge branch 'cgzones-mouse' 2021-09-20 16:29:17 +10:00
09ad8067f4 Merge branch 'mouse' of https://github.com/cgzones/htop into cgzones-mouse 2021-09-20 16:29:05 +10:00
bda3ee2b81 Update ReadMe
Add license and repology badge, improve several wording, improve
several sections.

[skip ci]
2021-09-19 14:47:32 +02:00
bdb015ffa3 Header: do not let multi-column meters expand to empty neighbors
Extending to right neighbors is intended for text meters with an
overlong content, so the whole text is shown if possible.
Multi column meters, like the combined memory and swap meter, position
its text depending on the given total width; keep the position to the
original assigned header slot.

Short term resolution for #796
2021-09-18 17:21:32 +02:00
80a515abcc Fix typo 2021-09-18 15:55:21 +02:00
5000cefc13 Fix typo in gettime implementation on darwin 2021-09-18 14:14:23 +02:00
bf7d98e7ac MainPanel: do not reset on disabled mouse events
Do not reset the hidden process selection (and hidden function bar) on mouse events, when mouse support is disabled.
2021-09-18 11:48:32 +02:00
c096712b8d Merge pull request #779 from BenBE/percent-highlight
Highlight percentages similar to large numbers
2021-09-14 12:53:33 +10:00
be82448bd5 Process_printPercentage using one color transition
Update Process_printPercentage such that color change happens only once at 100% and beyond.
2021-09-14 11:16:34 +10:00
68c00b9cdb Header: cache number of columns in HeaderLayout_getColumns
The header layout, and therefore the number of columns, should never
be changed within such loop.
2021-09-12 18:35:24 +02:00
3c8d586a1c Linux: recalculate LRS value
The LRS value is only zero in the first cycle; drop the check to
recalculate while running.
2021-09-12 18:20:40 +02:00
3869c43393 valgrind: rewrite ncurses suppressions
Simplify and update valgrind suppressions for possible leak and
reachable memory inside ncurses.
2021-09-11 00:07:23 +02:00
fcca4c2f2d valgrind: track origin of uninitialised values 2021-09-11 00:07:23 +02:00
dd88510dcd HeaderOptionsPanel: select the current not saved option
Select the current active header layout, not the current saved layout
from the settings, as the value gets only saved back from the active
header to settings on closing the setup menu.

Closes: #785
2021-09-11 00:06:41 +02:00
43ffdb0eda Linux: zero CPU data after allocation
Zero all the CPU data, like totalPeriod, after its memory allocation via
realloc(3).

    Conditional jump or move depends on uninitialised value(s)
       at 0x132A9B: LinuxProcessList_scanCPUTime (LinuxProcessList.c:1928)
       by 0x1358C3: ProcessList_goThroughEntries (LinuxProcessList.c:2079)
        by 0x12A79A: ProcessList_scan (ProcessList.c:627)
        by 0x11CA67: CommandLine_run (CommandLine.c:357)
        by 0x4A81E49: (below main) (libc-start.c:314)
      Uninitialised value was created by a heap allocation
        at 0x48396C5: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
        by 0x12F633: xRealloc (XUtils.c:64)
        by 0x12F633: xReallocArray (XUtils.c:78)
        by 0x1325A8: LinuxProcessList_updateCPUcount (LinuxProcessList.c:207)
        by 0x134E0A: ProcessList_new (LinuxProcessList.c:284)
        by 0x11C8D0: CommandLine_run (CommandLine.c:301)
        by 0x4A81E49: (below main) (libc-start.c:314)
2021-09-11 00:04:00 +02:00
bf395e10c5 Add xReallocArrayZero() helper
Add helper function to reallocate an dynamic allocated array including
zeroing the newly allocated memory.
2021-09-11 00:04:00 +02:00
8f259bc5e1 MemorySwapMeter: align with CPU meter
Use the same width for each sub meter to align with CPU meter.
Currently if the total width is even, so it does not split exactly into
2 equal parts plus 1 (for the middle space character column), the extra
column is added to the second meter width.

Closes: #783
2021-09-10 17:09:48 +02:00
38e6136b82 CRT: close backup stderr file after reset
Close the backup file descriptor of original stderr once it has been
restored at stderr.
2021-09-10 17:01:26 +02:00
589b0733d9 Settings: set ok when reading configuration from sysconfdir
Without this htoprc from sysconfdir is ignored and default meters
are loaded.
2021-09-10 08:58:58 +02:00
c9b58c7fbe Add missing end-of-line to htoprc file version mismatch warning 2021-09-08 12:13:56 +10:00
ca06e68037 Fix a typo in a configure.ac comment 2021-09-08 12:11:58 +10:00
a516e0852e Update configure to reflect rc2 in the version 2021-09-05 19:07:29 +02:00
3f805cf347 Highlight large percentages similar to large memory columns 2021-09-05 18:49:05 +02:00
556d7c03e8 Add a Process_printPercentage helper routine
Replace several open-coded variants of percentage formatting.
This function has been ported from Hishams old 'next' branch.
2021-09-05 18:47:07 +02:00
0925c54caa Drop redundant semicolons 2021-09-04 14:17:37 +02:00
d0f5b61aa5 hwloc: use int in hwloc_bitmap_foreach_begin loop
Affinity.c:67:10: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned int' changed the value to 4294967295 (32-bit, unsigned)
2021-09-04 09:48:53 +02:00
284f8c5e0b configure: output vserver as implied if ancient-vserver is enabled
The build time configuration ancient-vserver implies the configuration
vserver; say so in the configure status report if only ancient-vserver
has been specified.

Also indent with 3 spaces.
2021-09-04 09:48:53 +02:00
11b65a2861 Header: use upper case floating point suffix 2021-09-04 09:48:53 +02:00
b85b718e69 Settings: enclose casted macro argument in parenthesis 2021-09-04 09:48:53 +02:00
7891cdc552 Reduce variable scope
Also avoid declaring variables of different type, pointer and array, in
the same line.
2021-09-04 09:48:53 +02:00
b9fdf1c2a1 ColumnsPanel: drop unused struct declaration 2021-09-04 09:48:53 +02:00
2844429f15 NetBSD: scale CPU frequencies
Use a value type of 'long int' to avoid ENOMEM failures of sysctl(3).

Also check for "machdep.tsc_freq", scaled in MHz.
2021-09-03 12:17:45 +02:00
3834f2a68f NetBSD: misc const additions 2021-09-03 12:17:45 +02:00
343c2e58be NetBSD: update process fields
Populate fields to ttyname, minflt, majflt and processor.
2021-09-03 12:17:45 +02:00
fd2c4f5ddd NetBSD: fix reading environment variables of processes
kvm_getenvv(3) seems not to work with kvm_openfiles(..., KVM_NO_FILES,
...)
2021-09-03 12:17:45 +02:00
7f95ed8528 NetBSD: simplify Platform_setMemoryValues 2021-09-03 12:17:45 +02:00
9579d9b7aa NetBSD: silence dropping const qualifier on define_key(3)
On NetBSD define_key(3) has the prototype

    int define_key(char *sequence, int key_symbol);
2021-09-03 12:17:45 +02:00
0580dbb202 NetBSD: color process state P as running
On NetBSD state 'R' means runnable not running.

Improve the color identifier name accordingly.
2021-09-03 12:17:45 +02:00
c0c2bb98a2 Add completion handling for dynamic meters and columns
Be sure to free dynamic memory allocated for meters and
columns strings, no-op on platforms other than pcp.

Closes #774
2021-09-03 09:47:01 +02:00
9b30870eec Merge pull request #775 from cgzones/pcp
PCP: do not set exe to empty string
2021-09-03 12:08:00 +10:00
25c945e2ef PCP: do not set exe to empty string
In case the executable is an empty string, e.g. if pcp is run by an
unprivileged user, do not set procExe to an empty value, which breaks
the formatting of the PROCEXE column and the merged-cmdline logic.
2021-09-02 23:37:53 +02:00
f94934472f Linux: rework disk-io parsing
Generalize sub-diskname handling, like sdb1/sdb2, to not count the
usage twice with the aggregate top-diskname, like sdb.
Rely on /proc/diskstats being ordered, e.g. no sub-diskname precedes its
top-diskname.

Closes: #675
2021-09-02 22:12:58 +02:00
becd33795c Settings: create default meters on no existing config file
If htop is started for the first time and no configuration file exists
the header is empty cause no meters are added as a default.

Add the default meters if parsing all available configuration paths
failed.
2021-09-02 08:03:21 +02:00
74f99e3693 linux: simplify recheck condition
`recheck` is calculated modulo 2048, so its maximum value is 2047.
Drop the quite similar (up to 27 milliseconds) explicit check against
2000.
2021-09-02 08:03:21 +02:00
e1f4645bd1 Process: drop unused merged-command bit fields 2021-09-02 08:03:21 +02:00
0afd0fe572 linux: color void delay accounting values gray
Use the color gray, similar to other process fields, if the delay
accounting value is either 0 (or very small) or cannot be accessed, e.g.
by an unprivileged user.
2021-09-02 08:03:21 +02:00
ff336b652c linux: drop unused macro IOPriority_error 2021-09-02 08:03:21 +02:00
58a59c11f4 linux: drop dead process field column DIRTY
The field for dirty pages in /proc/[pid]/statm is always 0 since Linux
2.6 (see man:proc(5)).
2021-09-02 08:03:21 +02:00
3f806368e0 CPUMeter: use correct buffer size 2021-09-02 08:03:21 +02:00
4855d92469 travis-ci: update
Drop explicit CFLAGS specification as `-Wno-c11-extensions` is enabled
on FreeBSD by the configure script.

Run and check `make install` and `make installcheck`.
2021-09-02 08:03:21 +02:00
b81bb9038c Fix resource leaks dealing with unrecognised config file version
Plug leaks of an open file descriptor and dynamically allocated
'option' when we bail out early reading unknown config version.
2021-08-31 08:08:01 +02:00
1f2f567ca1 Fix meterPanels size calculation for dynamic array allocation 2021-08-31 08:08:01 +02:00
393330239e Small editorial fixes to ChangeLog 2021-08-27 09:31:06 +02:00
d2c34259b4 Remove trailing whitespace in changelog for CI checks 2021-08-27 12:19:50 +10:00
858ad8029d Update configure to reflect rc1 in the version 2021-08-27 12:14:23 +10:00
212 changed files with 1047 additions and 613 deletions

View File

@ -9,7 +9,8 @@ os:
script:
- ./autogen.sh
# clang might warn about C11 generic selections in isnan()
- CFLAGS=-Wno-c11-extensions ./configure --enable-werror
- ./configure --enable-werror
- make -k
- CFLAGS=-Wno-c11-extensions make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
- make distcheck DISTCHECK_CONFIGURE_FLAGS=--enable-werror
- sudo make install
- make installcheck

View File

@ -1,7 +1,7 @@
/*
htop - Action.c
(C) 2015 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -519,7 +519,7 @@ static Htop_Reaction actionHelp(State* st) {
int line = 0;
mvaddstr(line++, 0, "htop " VERSION " - " COPYRIGHT);
mvaddstr(line++, 0, "Released under the GNU GPLv2. See 'man' page for more info.");
mvaddstr(line++, 0, "Released under the GNU GPLv2+. See 'man' page for more info.");
attrset(CRT_colors[DEFAULT_COLOR]);
line++;

View File

@ -3,7 +3,7 @@
/*
htop - Action.h
(C) 2015 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -2,7 +2,7 @@
htop - Affinity.c
(C) 2004-2011 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -63,9 +63,9 @@ Affinity* Affinity_get(const Process* proc, ProcessList* pl) {
Affinity_add(affinity, i);
}
} else {
unsigned int id;
hwloc_bitmap_foreach_begin(id, cpuset);
Affinity_add(affinity, id);
int id;
hwloc_bitmap_foreach_begin(id, cpuset)
Affinity_add(affinity, (unsigned)id);
hwloc_bitmap_foreach_end();
}
}

View File

@ -4,7 +4,7 @@
htop - Affinity.h
(C) 2004-2011 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - AffinityPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -425,9 +425,9 @@ Affinity* AffinityPanel_getAffinity(Panel* super, ProcessList* pl) {
Affinity* affinity = Affinity_new(pl);
#ifdef HAVE_LIBHWLOC
unsigned int i;
int i;
hwloc_bitmap_foreach_begin(i, this->workCpuset)
Affinity_add(affinity, i);
Affinity_add(affinity, (unsigned)i);
hwloc_bitmap_foreach_end();
#else
for (int i = 0; i < Vector_size(this->cpuids); i++) {

View File

@ -3,7 +3,7 @@
/*
htop - AffinityPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - AvailableColumnsPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - AvailableColumnsPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - AvailableMetersPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - AvailableMetersPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - BatteryMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).

View File

@ -3,7 +3,7 @@
/*
htop - BatteryMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
This meter written by Ian P. Hands (iphands@gmail.com, ihands@redhat.com).

View File

@ -1,7 +1,7 @@
/*
htop - CPUMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -52,9 +52,9 @@ static void CPUMeter_init(Meter* this) {
// Custom uiName runtime logic to include the param (processor)
static void CPUMeter_getUiName(const Meter* this, char* buffer, size_t length) {
if (this->param > 0)
xSnprintf(buffer, sizeof(length), "%s %u", Meter_uiName(this), this->param);
xSnprintf(buffer, length, "%s %u", Meter_uiName(this), this->param);
else
xSnprintf(buffer, sizeof(length), "%s", Meter_uiName(this));
xSnprintf(buffer, length, "%s", Meter_uiName(this));
}
static void CPUMeter_updateValues(Meter* this) {
@ -381,6 +381,7 @@ const MeterClass AllCPUs2Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "AllCPUs2",
@ -401,6 +402,7 @@ const MeterClass LeftCPUsMeter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "LeftCPUs",
@ -421,6 +423,7 @@ const MeterClass RightCPUsMeter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "RightCPUs",
@ -441,6 +444,7 @@ const MeterClass LeftCPUs2Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "LeftCPUs2",
@ -461,6 +465,7 @@ const MeterClass RightCPUs2Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "RightCPUs2",
@ -481,6 +486,7 @@ const MeterClass AllCPUs4Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "AllCPUs4",
@ -501,6 +507,7 @@ const MeterClass LeftCPUs4Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "LeftCPUs4",
@ -521,6 +528,7 @@ const MeterClass RightCPUs4Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "RightCPUs4",
@ -541,6 +549,7 @@ const MeterClass AllCPUs8Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "AllCPUs8",
@ -561,6 +570,7 @@ const MeterClass LeftCPUs8Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "LeftCPUs8",
@ -581,6 +591,7 @@ const MeterClass RightCPUs8Meter_class = {
},
.updateValues = AllCPUsMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.total = 100.0,
.attributes = CPUMeter_attributes,
.name = "RightCPUs8",

View File

@ -3,7 +3,7 @@
/*
htop - CPUMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

101
CRT.c
View File

@ -1,7 +1,7 @@
/*
htop - CRT.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -21,14 +21,22 @@ in the source distribution for its full text.
#include "ProvideCurses.h"
#include "XUtils.h"
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
#if !defined(NDEBUG) && defined(HAVE_MEMFD_CREATE)
#include <sys/mman.h>
#endif
#if defined(HAVE_LIBUNWIND_H) && defined(HAVE_LIBUNWIND)
# define PRINT_BACKTRACE
# define UNW_LOCAL_ONLY
# include <libunwind.h>
# if defined(HAVE_DLADDR)
# include <dlfcn.h>
# endif
#elif defined(HAVE_EXECINFO_H)
# define PRINT_BACKTRACE
# include <execinfo.h>
#endif
#define ColorIndex(i,j) ((7-(i))*8+(j))
@ -138,7 +146,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[PROCESS_GIGABYTES] = ColorPair(Green, Black),
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan, Black),
[PROCESS_TREE] = ColorPair(Cyan, Black),
[PROCESS_R_STATE] = ColorPair(Green, Black),
[PROCESS_RUN_STATE] = ColorPair(Green, Black),
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
@ -240,7 +248,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[PROCESS_GIGABYTES] = A_BOLD,
[PROCESS_BASENAME] = A_BOLD,
[PROCESS_TREE] = A_BOLD,
[PROCESS_R_STATE] = A_BOLD,
[PROCESS_RUN_STATE] = A_BOLD,
[PROCESS_D_STATE] = A_BOLD,
[PROCESS_HIGH_PRIORITY] = A_BOLD,
[PROCESS_LOW_PRIORITY] = A_DIM,
@ -342,7 +350,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[PROCESS_GIGABYTES] = ColorPair(Green, White),
[PROCESS_BASENAME] = ColorPair(Blue, White),
[PROCESS_TREE] = ColorPair(Green, White),
[PROCESS_R_STATE] = ColorPair(Green, White),
[PROCESS_RUN_STATE] = ColorPair(Green, White),
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, White),
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, White),
[PROCESS_LOW_PRIORITY] = ColorPair(Green, White),
@ -444,7 +452,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[PROCESS_GIGABYTES] = ColorPair(Green, Black),
[PROCESS_BASENAME] = ColorPair(Green, Black),
[PROCESS_TREE] = ColorPair(Blue, Black),
[PROCESS_R_STATE] = ColorPair(Green, Black),
[PROCESS_RUN_STATE] = ColorPair(Green, Black),
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
@ -546,7 +554,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[PROCESS_GIGABYTES] = ColorPair(Green, Blue),
[PROCESS_BASENAME] = A_BOLD | ColorPair(Cyan, Blue),
[PROCESS_TREE] = ColorPair(Cyan, Blue),
[PROCESS_R_STATE] = ColorPair(Green, Blue),
[PROCESS_RUN_STATE] = ColorPair(Green, Blue),
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Blue),
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Blue),
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Blue),
@ -652,7 +660,7 @@ static int CRT_colorSchemes[LAST_COLORSCHEME][LAST_COLORELEMENT] = {
[PROCESS_THREAD_BASENAME] = A_BOLD | ColorPair(Blue, Black),
[PROCESS_COMM] = ColorPair(Magenta, Black),
[PROCESS_THREAD_COMM] = ColorPair(Yellow, Black),
[PROCESS_R_STATE] = ColorPair(Green, Black),
[PROCESS_RUN_STATE] = ColorPair(Green, Black),
[PROCESS_D_STATE] = A_BOLD | ColorPair(Red, Black),
[PROCESS_HIGH_PRIORITY] = ColorPair(Red, Black),
[PROCESS_LOW_PRIORITY] = ColorPair(Green, Black),
@ -772,6 +780,8 @@ static void dumpStderr(void) {
fsync(STDERR_FILENO);
dup2(stderrRedirectBackupFd, STDERR_FILENO);
close(stderrRedirectBackupFd);
stderrRedirectBackupFd = -1;
lseek(stderrRedirectNewFd, 0, SEEK_SET);
bool header = false;
@ -886,6 +896,10 @@ void CRT_init(const Settings* settings, bool allowUnicode) {
}
if (termType && (String_startsWith(termType, "xterm") || String_eq(termType, "vt220"))) {
#ifdef HTOP_NETBSD
#define define_key(s_, k_) define_key((char*)s_, k_)
IGNORE_WCASTQUAL_BEGIN
#endif
define_key("\033[H", KEY_HOME);
define_key("\033[F", KEY_END);
define_key("\033[7~", KEY_HOME);
@ -906,6 +920,10 @@ void CRT_init(const Settings* settings, bool allowUnicode) {
sequence[1] = c;
define_key(sequence, KEY_ALT('A' + (c - 'a')));
}
#ifdef HTOP_NETBSD
IGNORE_WCASTQUAL_END
#undef define_key
#endif
}
CRT_installSignalHandlers();
@ -998,6 +1016,59 @@ void CRT_setColors(int colorScheme) {
CRT_colors = CRT_colorSchemes[colorScheme];
}
#ifdef PRINT_BACKTRACE
static void print_backtrace(void) {
#if defined(HAVE_LIBUNWIND_H) && defined(HAVE_LIBUNWIND)
unw_context_t context;
unw_getcontext(&context);
unw_cursor_t cursor;
unw_init_local(&cursor, &context);
unsigned int item = 0;
while (unw_step(&cursor) > 0) {
unw_word_t pc;
unw_get_reg(&cursor, UNW_REG_IP, &pc);
if (pc == 0)
break;
char symbolName[256] = "?";
unw_word_t offset = 0;
unw_get_proc_name(&cursor, symbolName, sizeof(symbolName), &offset);
unw_proc_info_t pip;
pip.unwind_info = NULL;
const char* fname = "?";
const void* ptr = 0;
if (unw_get_proc_info(&cursor, &pip) == 0) {
ptr = (const void*)(pip.start_ip + offset);
#ifdef HAVE_DLADDR
Dl_info dlinfo;
if (dladdr(ptr, &dlinfo) && dlinfo.dli_fname && *dlinfo.dli_fname)
fname = dlinfo.dli_fname;
#endif
}
const char* frame = "";
if (unw_is_signal_frame(&cursor) > 0)
frame = "{signal frame}";
fprintf(stderr, "%2u: %#14lx %s (%s+%#lx) [%p]%s%s\n", item++, pc, fname, symbolName, offset, ptr, frame ? " " : "", frame);
}
#elif defined(HAVE_EXECINFO_H)
void* backtraceArray[256];
size_t size = backtrace(backtraceArray, ARRAYSIZE(backtraceArray));
backtrace_symbols_fd(backtraceArray, size, STDERR_FILENO);
#else
#error No implementation for print_backtrace()!
#endif
}
#endif
void CRT_handleSIGSEGV(int signal) {
CRT_done();
@ -1012,7 +1083,7 @@ void CRT_handleSIGSEGV(int signal) {
" - Likely steps to reproduce (How did it happen?)\n"
);
#ifdef HAVE_EXECINFO_H
#ifdef PRINT_BACKTRACE
fprintf(stderr, " - Backtrace of the issue (see below)\n");
#endif
@ -1038,16 +1109,14 @@ void CRT_handleSIGSEGV(int signal) {
Settings_write(CRT_crashSettings, true);
fprintf(stderr, "\n\n");
#ifdef HAVE_EXECINFO_H
#ifdef PRINT_BACKTRACE
fprintf(stderr,
"Backtrace information:\n"
"----------------------\n"
);
void* backtraceArray[256];
print_backtrace();
size_t size = backtrace(backtraceArray, ARRAYSIZE(backtraceArray));
backtrace_symbols_fd(backtraceArray, size, STDERR_FILENO);
fprintf(stderr,
"\n"
"To make the above information more practical to work with, "

10
CRT.h
View File

@ -3,7 +3,7 @@
/*
htop - CRT.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -74,7 +74,7 @@ typedef enum ColorElements_ {
PROCESS_MEGABYTES,
PROCESS_GIGABYTES,
PROCESS_TREE,
PROCESS_R_STATE,
PROCESS_RUN_STATE,
PROCESS_D_STATE,
PROCESS_BASENAME,
PROCESS_HIGH_PRIORITY,
@ -147,9 +147,9 @@ void CRT_fatalError(const char* note) ATTR_NORETURN;
void CRT_handleSIGSEGV(int signal) ATTR_NORETURN;
#define KEY_WHEELUP KEY_F(20)
#define KEY_WHEELDOWN KEY_F(21)
#define KEY_RECLICK KEY_F(22)
#define KEY_WHEELUP KEY_F(30)
#define KEY_WHEELDOWN KEY_F(31)
#define KEY_RECLICK KEY_F(32)
#define KEY_ALT(x) (KEY_F(64 - 26) + ((x) - 'A'))
extern const char* CRT_degreeSign;

View File

@ -1,7 +1,7 @@
/*
htop - CategoriesPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -40,7 +40,7 @@ static void CategoriesPanel_delete(Object* object) {
static void CategoriesPanel_makeMetersPage(CategoriesPanel* this) {
size_t columns = HeaderLayout_getColumns(this->scr->header->headerLayout);
MetersPanel** meterPanels = xMallocArray(columns, sizeof(MetersPanel));
MetersPanel** meterPanels = xMallocArray(columns, sizeof(MetersPanel*));
for (size_t i = 0; i < columns; i++) {
char titleBuffer[32];

View File

@ -3,7 +3,7 @@
/*
htop - CategoriesPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,5 +1,22 @@
What's new in version 3.1.0
What's new in version 3.1.1
* Update license headers to explicitly say GPLv2+
* Document minimum version for libcap (thanks to James Brown)
* Fix mouse wheel collision with autogroups nice adjustment
* Adjust Makefile.am macro definitions for older automake versions
* Ensure consistent reporting of MemoryMeter 'used' memory
* Report hugepage memory as real and used memory (as before)
* Handle procExeDeleted, usesDeletedLib without mergedCommandline mode
* Validate meter configuration before proceeding beyond htoprc parsing
* Properly release memory on partially read configuration
* Handle interrupted sampling from within libpcp PDU transfers
* On Linux, provide O_PATH value if not defined
* On Linux, always compute procExeDeleted if already set
* Workaround for Rosetta 2 on Darwin (thanks to Alexander Momchilov)
* Fix FreeBSD cmdline memory leak in Process_updateCmdline, and
* Plug a Disk I/O meter memory leak on FreeBSD (thanks to Ximalas)
What's new in version 3.1.0
* Updated COPYING file to remove the PLPA exemption (appendix 2)
With this change the license is now GPLv2 without any additional wording.
@ -26,10 +43,11 @@ What's new in version 3.1.0
Moving this column to be handled as a platform-independently available
information simplifies the markup of the command line.
* Introduce configuration file versioning and config_reader_min_version
Starting with this version the configuration file contains an version
Starting with this version the configuration file contains a version
identifying the minimum version of the configuration parser needed to
fully understand the configuration file format.
Old configuration file formats are automatically upgraded on startup.
Old configuration file formats are automatically upgraded when
saving the config file (htoprc).
* Make the configuration parser friendlier to users (thanks to Bart Bakker)
With this change only settings that cannot be parsed properly are
reset to their defaults.
@ -48,12 +66,12 @@ What's new in version 3.1.0
* Option and key ("*") to collapse / expand all branches under PID 1
(and PID 2 if kernel threads are shown) (thanks to Krishna Chaitanya)
* Keep following a process when inverting the sort order, displaying
the help screen or hiding/unhiding userland threads
the help screen or hiding/unhiding userland threads.
If a thread is currently selected the selection is updated to point
to the thread's parent process. (thanks to Gonzalo, et.al.)
* Reorder process scanning to be performed before updating the display
of the meters in the header
* Always check the user for a process for any changes
* Always check the user for a process for any changes.
This affects multiple platforms that previously didn't correctly handle
the user field for a process to change at runtime (e.g. due to seteuid
or similar syscalls).
@ -105,14 +123,14 @@ What's new in version 3.1.0
* Correctly color the ZFS ARC ratio (thanks to Ross Williams)
* Bugfixes related to CPU time display/calculations for darwin on M1 systems
(thanks to Alexander Momchilov)
* Harmonize the handling of multiple batteries across different platforms
* Harmonize the handling of multiple batteries across different platforms.
The system is now considered to run on AC if at least one power supply
marked as AC is found in the system.
Battery capacity is summed up over all batteries found.
This also changes the old behavior that batteries reported by the
system after the first AC adapter where sometimes ignored.
* Correctly handle multiple batteries on Darwin
Resolves a possible memory leak on systems with multiple batteries
* Correctly handle multiple batteries on Darwin.
Resolves a possible memory leak on systems with multiple batteries.
* Handle Linux Shmem being part of Cached in the MemoryMeter
* Add SwapCached to the Linux swap meter (thanks to David Zarzycki)
* Convert process time to days if applicable (thanks to David Zarzycki)
@ -138,7 +156,7 @@ What's new in version 3.1.0
* Add command line option to drop Linux capabilities
* Support scheduler affinity on platforms beyond Linux
* Report on any failure to write the configuration file
* Cache stderr to be able to print assert messages
* Cache stderr to be able to print assert messages.
These messages are shown in case htop terminates unexpectedly.
* Print current settings on crash
* Reset signal handlers on program exit

View File

@ -1,7 +1,7 @@
/*
htop - ClockMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - ClockMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - ColorsPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - ColorsPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - ColumnsPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -118,12 +118,6 @@ const PanelClass ColumnsPanel_class = {
.eventHandler = ColumnsPanel_eventHandler
};
typedef struct {
Panel* super;
unsigned int id;
unsigned int offset;
} DynamicIterator;
static void ColumnsPanel_add(Panel* super, unsigned int key, Hashtable* columns) {
const char* name;
if (key < LAST_PROCESSFIELD) {

View File

@ -3,7 +3,7 @@
/*
htop - ColumnsPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -2,7 +2,7 @@
htop - CommandLine.c
(C) 2004-2011 Hisham H. Muhammad
(C) 2020-2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -47,7 +47,7 @@ static void printVersionFlag(const char* name) {
static void printHelpFlag(const char* name) {
printf("%s " VERSION "\n"
COPYRIGHT "\n"
"Released under the GNU GPLv2.\n\n"
"Released under the GNU GPLv2+.\n\n"
"-C --no-color Use a monochrome color scheme\n"
"-d --delay=DELAY Set the delay between updates, in tenths of seconds\n"
"-F --filter=FILTER Show only the commands matching the given filter\n"
@ -393,10 +393,8 @@ int CommandLine_run(const char* name, int argc, char** argv) {
/* Delete these last, since they can get accessed in the crash handler */
Settings_delete(settings);
if (dc)
Hashtable_delete(dc);
if (dm)
Hashtable_delete(dm);
DynamicColumns_delete(dc);
DynamicMeters_delete(dm);
return 0;
}

View File

@ -4,7 +4,7 @@
htop - CommandLine.h
(C) 2004-2011 Hisham H. Muhammad
(C) 2020-2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - Compat.c
(C) 2020 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - Compat.h
(C) 2020 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - DateMeter.c
(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
Released under the GNU GPL, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - DateMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - DateTimeMeter.c
(C) 2004-2020 Hisham H. Muhammad, Michael Schönitzer
Released under the GNU GPL, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - DateTimeMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - DiskIOMeter.c
(C) 2020 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - DiskIOMeter.h
(C) 2020 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - DisplayOptionsPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - DisplayOptionsPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@ htop - DynamicColumn.c
(C) 2021 Sohaib Mohammed
(C) 2021 htop dev team
(C) 2021 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -22,6 +22,13 @@ Hashtable* DynamicColumns_new(void) {
return Platform_dynamicColumns();
}
void DynamicColumns_delete(Hashtable* dynamics) {
if (dynamics) {
Platform_dynamicColumnsDone(dynamics);
Hashtable_delete(dynamics);
}
}
const char* DynamicColumn_init(unsigned int key) {
return Platform_dynamicColumnInit(key);
}

View File

@ -21,6 +21,8 @@ typedef struct DynamicColumn_ {
Hashtable* DynamicColumns_new(void);
void DynamicColumns_delete(Hashtable* dynamics);
const char* DynamicColumn_init(unsigned int key);
const DynamicColumn* DynamicColumn_lookup(Hashtable* dynamics, unsigned int key);

View File

@ -2,7 +2,7 @@
htop - DynamicMeter.c
(C) 2021 htop dev team
(C) 2021 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -38,6 +38,13 @@ Hashtable* DynamicMeters_new(void) {
return Platform_dynamicMeters();
}
void DynamicMeters_delete(Hashtable* dynamics) {
if (dynamics) {
Platform_dynamicMetersDone(dynamics);
Hashtable_delete(dynamics);
}
}
typedef struct {
unsigned int key;
const char* name;

View File

@ -17,6 +17,8 @@ typedef struct DynamicMeter_ {
Hashtable* DynamicMeters_new(void);
void DynamicMeters_delete(Hashtable* dynamics);
const char* DynamicMeter_lookup(Hashtable* dynamics, unsigned int key);
bool DynamicMeter_search(Hashtable* dynamics, const char* name, unsigned int* key);

View File

@ -1,7 +1,7 @@
/*
htop - FunctionBar.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - FunctionBar.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - Hashtable.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - Hashtable.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - Header.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -86,8 +86,9 @@ static void Header_addMeterByName(Header* this, const char* name, MeterModeId mo
if (paren) {
int ok = sscanf(paren, "(%10u)", &param); // CPUMeter
if (!ok) {
char* end, dynamic[32] = {0};
char dynamic[32] = {0};
if (sscanf(paren, "(%30s)", dynamic)) { // DynamicMeter
char* end;
if ((end = strrchr(dynamic, ')')) == NULL)
return; // htoprc parse failure
*end = '\0';
@ -195,25 +196,28 @@ void Header_draw(const Header* this) {
}
const int width = COLS - pad;
int x = pad;
float roundingLoss = 0.0f;
float roundingLoss = 0.0F;
Header_forEachColumn(this, col) {
Vector* meters = this->columns[col];
float colWidth = (float)width * HeaderLayout_layouts[this->headerLayout].widths[col] / 100.0f;
float colWidth = (float)width * HeaderLayout_layouts[this->headerLayout].widths[col] / 100.0F;
roundingLoss += colWidth - floorf(colWidth);
if (roundingLoss >= 1.0f) {
colWidth += 1.0f;
roundingLoss -= 1.0f;
if (roundingLoss >= 1.0F) {
colWidth += 1.0F;
roundingLoss -= 1.0F;
}
for (int y = (pad / 2), i = 0; i < Vector_size(meters); i++) {
Meter* meter = (Meter*) Vector_get(meters, i);
float actualWidth = colWidth;
if (meter->mode == TEXT_METERMODE) {
/* Let meters in text mode expand to the right on empty neighbors;
except for multi column meters. */
if (meter->mode == TEXT_METERMODE && !Meter_isMultiColumn(meter)) {
for (int j = 1; j < meter->columnWidthCount; j++) {
actualWidth += (float)width * HeaderLayout_layouts[this->headerLayout].widths[col + j] / 100.0f;
actualWidth += (float)width * HeaderLayout_layouts[this->headerLayout].widths[col + j] / 100.0F;
}
}

View File

@ -3,7 +3,7 @@
/*
htop - Header.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -23,7 +23,7 @@ typedef struct Header_ {
int height;
} Header;
#define Header_forEachColumn(this_, i_) for (size_t (i_)=0; (i_) < HeaderLayout_getColumns((this_)->headerLayout); ++(i_))
#define Header_forEachColumn(this_, i_) for (size_t (i_)=0, H_fEC_numColumns_ = HeaderLayout_getColumns((this_)->headerLayout); (i_) < H_fEC_numColumns_; ++(i_))
Header* Header_new(ProcessList* pl, Settings* settings, HeaderLayout hLayout);

View File

@ -3,7 +3,7 @@
/*
htop - HeaderLayout.h
(C) 2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - HeaderOptionsPanel.c
(C) 2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -82,6 +82,6 @@ HeaderOptionsPanel* HeaderOptionsPanel_new(Settings* settings, ScreenManager* sc
for (int i = 0; i < LAST_HEADER_LAYOUT; i++) {
Panel_add(super, (Object*) CheckItem_newByVal(HeaderLayout_layouts[i].description, false));
}
CheckItem_set((CheckItem*)Panel_get(super, settings->hLayout), true);
CheckItem_set((CheckItem*)Panel_get(super, scr->header->headerLayout), true);
return this;
}

View File

@ -3,7 +3,7 @@
/*
htop - ColorsPanel.h
(C) 2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - HostnameMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - HostnameMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - IncSet.c
(C) 2005-2012 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -156,7 +156,7 @@ bool IncSet_handleKey(IncSet* this, int ch, Panel* panel, IncMode_GetPanelValue
doSearch = false;
} else if (0 < ch && ch < 255 && isprint((unsigned char)ch)) {
if (mode->index < INCMODE_MAX) {
mode->buffer[mode->index] = ch;
mode->buffer[mode->index] = (char) ch;
mode->index++;
mode->buffer[mode->index] = 0;
if (mode->isFilter) {

View File

@ -3,7 +3,7 @@
/*
htop - IncSet.h
(C) 2005-2012 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - ListItem.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - ListItem.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - LoadAverageMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - LoadAverageMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -2,7 +2,7 @@
htop - ColumnsPanel.c
(C) 2004-2015 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -62,7 +62,13 @@ static HandlerResult MainPanel_eventHandler(Panel* super, int ch) {
return IGNORED;
/* reset on every normal key */
if (ch != ERR)
bool needReset = ch != ERR;
#ifdef HAVE_GETMOUSE
/* except mouse events while mouse support is disabled */
if (!(ch != KEY_MOUSE || this->state->settings->enableMouse))
needReset = false;
#endif
if (needReset)
this->state->hideProcessSelection = false;
if (EVENT_IS_HEADER_CLICK(ch)) {

View File

@ -4,7 +4,7 @@
htop - ColumnsPanel.h
(C) 2004-2015 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,3 +1,11 @@
if !HTOP_PCP
bin_PROGRAMS = htop
myhtopplatprogram = htop.c
else
bin_PROGRAMS = pcp-htop
myhtopplatprogram = pcp-htop.c
endif
dist_man_MANS = htop.1
EXTRA_DIST = \
$(dist_man_MANS) \
@ -181,7 +189,6 @@ linux_platform_sources = \
if HTOP_LINUX
AM_LDFLAGS += -rdynamic
myhtopplatprogram = htop
myhtopplatheaders = $(linux_platform_headers)
myhtopplatsources = $(linux_platform_sources)
endif
@ -214,7 +221,6 @@ freebsd_platform_sources = \
zfs/ZfsCompressedArcMeter.c
if HTOP_FREEBSD
myhtopplatprogram = htop
myhtopplatheaders = $(freebsd_platform_headers)
myhtopplatsources = $(freebsd_platform_sources)
endif
@ -240,7 +246,6 @@ dragonflybsd_platform_sources = \
generic/uname.c
if HTOP_DRAGONFLYBSD
myhtopplatprogram = htop
myhtopplatheaders = $(dragonflybsd_platform_headers)
myhtopplatsources = $(dragonflybsd_platform_sources)
endif
@ -266,7 +271,6 @@ netbsd_platform_sources = \
netbsd/NetBSDProcessList.c
if HTOP_NETBSD
myhtopplatprogram = htop
myhtopplatheaders = $(netbsd_platform_headers)
myhtopplatsources = $(netbsd_platform_sources)
endif
@ -292,7 +296,6 @@ openbsd_platform_sources = \
openbsd/Platform.c
if HTOP_OPENBSD
myhtopplatprogram = htop
myhtopplatheaders = $(openbsd_platform_headers)
myhtopplatsources = $(openbsd_platform_sources)
endif
@ -304,6 +307,7 @@ darwin_platform_headers = \
darwin/DarwinProcess.h \
darwin/DarwinProcessList.h \
darwin/Platform.h \
darwin/PlatformHelpers.h \
darwin/ProcessField.h \
generic/gettime.h \
generic/hostname.h \
@ -315,6 +319,7 @@ darwin_platform_headers = \
darwin_platform_sources = \
darwin/Platform.c \
darwin/PlatformHelpers.c \
darwin/DarwinProcess.c \
darwin/DarwinProcessList.c \
generic/gettime.c \
@ -326,7 +331,6 @@ darwin_platform_sources = \
if HTOP_DARWIN
AM_LDFLAGS += -framework IOKit -framework CoreFoundation
myhtopplatprogram = htop
myhtopplatheaders = $(darwin_platform_headers)
myhtopplatsources = $(darwin_platform_sources)
endif
@ -357,7 +361,6 @@ solaris_platform_sources = \
zfs/ZfsCompressedArcMeter.c
if HTOP_SOLARIS
myhtopplatprogram = htop
myhtopplatheaders = $(solaris_platform_headers)
myhtopplatsources = $(solaris_platform_sources)
endif
@ -393,10 +396,9 @@ pcp_platform_sources = \
zfs/ZfsCompressedArcMeter.c
if HTOP_PCP
myhtopplatprogram = pcp-htop
myhtopplatheaders = $(pcp_platform_headers)
myhtopplatsources = $(pcp_platform_sources)
pcp_htop_SOURCES = $(myhtopplatprogram).c $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
pcp_htop_SOURCES = $(myhtopplatprogram) $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
endif
# Unsupported
@ -416,15 +418,13 @@ unsupported_platform_sources = \
unsupported/UnsupportedProcessList.c
if HTOP_UNSUPPORTED
myhtopplatprogram = htop
myhtopplatsources = $(unsupported_platform_sources)
myhtopplatheaders = $(unsupported_platform_headers)
endif
# ----
bin_PROGRAMS = $(myhtopplatprogram)
htop_SOURCES = $(myhtopplatprogram).c $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
htop_SOURCES = $(myhtopplatprogram) $(myhtopheaders) $(myhtopplatheaders) $(myhtopsources) $(myhtopplatsources)
nodist_htop_SOURCES = config.h
target:

View File

@ -1,7 +1,7 @@
/*
htop - MemoryMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -36,7 +36,7 @@ static void MemoryMeter_updateValues(Meter* this) {
/* Do not print available memory in bar mode */
this->curItems = 4;
written = Meter_humanUnit(buffer, isnan(this->values[4]) ? this->values[0] : this->total - this->values[4], size);
written = Meter_humanUnit(buffer, this->values[0], size);
METER_BUFFER_CHECK(buffer, size, written);
METER_BUFFER_APPEND_CHR(buffer, size, '/');

View File

@ -3,7 +3,7 @@
/*
htop - MemoryMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - MemorySwapMeter.c
(C) 2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -33,10 +33,14 @@ static void MemorySwapMeter_updateValues(Meter* this) {
static void MemorySwapMeter_draw(Meter* this, int x, int y, int w) {
MemorySwapMeterData* data = this->meterData;
/* Use the same width for each sub meter to align with CPU meter */
const int colwidth = w / 2;
const int diff = w - colwidth * 2;
assert(data->memoryMeter->draw);
data->memoryMeter->draw(data->memoryMeter, x, y, w / 2);
data->memoryMeter->draw(data->memoryMeter, x, y, colwidth);
assert(data->swapMeter->draw);
data->swapMeter->draw(data->swapMeter, x + w / 2, y, w - w / 2);
data->swapMeter->draw(data->swapMeter, x + colwidth + diff, y, colwidth);
}
static void MemorySwapMeter_init(Meter* this) {
@ -91,6 +95,7 @@ const MeterClass MemorySwapMeter_class = {
},
.updateValues = MemorySwapMeter_updateValues,
.defaultMode = CUSTOM_METERMODE,
.isMultiColumn = true,
.name = "MemorySwap",
.uiName = "Memory & Swap",
.description = "Combined memory and swap usage",

View File

@ -3,7 +3,7 @@
/*
htop - MemorySwapMeter.h
(C) 2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - Meter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - Meter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -73,6 +73,7 @@ typedef struct MeterClass_ {
const char* const caption; /* prefix in the actual header */
const char* const description; /* optional meter description in header setup menu */
const uint8_t maxItems;
const bool isMultiColumn; /* whether the meter draws multiple sub-columns (defaults to false) */
} MeterClass;
#define As_Meter(this_) ((const MeterClass*)((this_)->super.klass))
@ -92,6 +93,7 @@ typedef struct MeterClass_ {
#define Meter_attributes(this_) As_Meter(this_)->attributes
#define Meter_name(this_) As_Meter(this_)->name
#define Meter_uiName(this_) As_Meter(this_)->uiName
#define Meter_isMultiColumn(this_) As_Meter(this_)->isMultiColumn
typedef struct GraphData_ {
struct timeval time;

View File

@ -1,7 +1,7 @@
/*
htop - MetersPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - MetersPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -2,7 +2,7 @@
htop - Object.c
(C) 2004-2012 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -4,7 +4,7 @@
htop - Object.h
(C) 2004-2012 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - OpenFilesScreen.c
(C) 2005-2006 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - OpenFilesScreen.h
(C) 2005-2006 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - OptionItem.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - OptionItem.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - Panel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -453,7 +453,7 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) {
}
if (len < 99) {
buffer[len] = ch;
buffer[len] = (char) ch;
buffer[len + 1] = '\0';
}
@ -470,7 +470,7 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) {
// if current word did not match,
// retry considering the character the start of a new word.
buffer[0] = ch;
buffer[0] = (char) ch;
buffer[1] = '\0';
}

View File

@ -3,7 +3,7 @@
/*
htop - Panel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -67,7 +67,7 @@ struct Panel_ {
int selectedLen;
void* eventHandlerState;
int scrollV;
short scrollH;
int scrollH;
bool needsRedraw;
bool wasFocus;
FunctionBar* currentBar;

View File

@ -2,7 +2,7 @@
htop - Process.c
(C) 2004-2015 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -511,6 +511,12 @@ void Process_makeCommandStr(Process* this) {
if (cmdlineBasenameEnd > cmdlineBasenameStart)
WRITE_HIGHLIGHT(showProgramPath ? cmdlineBasenameStart : 0, cmdlineBasenameEnd - cmdlineBasenameStart, baseAttr, CMDLINE_HIGHLIGHT_FLAG_BASENAME);
if (this->procExeDeleted)
WRITE_HIGHLIGHT(showProgramPath ? cmdlineBasenameStart : 0, cmdlineBasenameEnd - cmdlineBasenameStart, delExeAttr, CMDLINE_HIGHLIGHT_FLAG_DELETED);
else if (this->usesDeletedLib)
WRITE_HIGHLIGHT(showProgramPath ? cmdlineBasenameStart : 0, cmdlineBasenameEnd - cmdlineBasenameStart, delLibAttr, CMDLINE_HIGHLIGHT_FLAG_DELETED);
(void)stpcpyWithNewlineConversion(str, cmdline + (showProgramPath ? 0 : cmdlineBasenameStart));
return;
@ -707,6 +713,26 @@ void Process_printLeftAlignedField(RichString* str, int attr, const char* conten
RichString_appendChr(str, attr, ' ', width + 1 - columns);
}
void Process_printPercentage(float val, char* buffer, int n, int* attr) {
if (val >= 0) {
if (val < 99.9F) {
if (val < 0.05F) {
*attr = CRT_colors[PROCESS_SHADOW];
}
xSnprintf(buffer, n, "%4.1f ", val);
} else if (val < 999) {
*attr = CRT_colors[PROCESS_MEGABYTES];
xSnprintf(buffer, n, "%3d. ", (int)val);
} else {
*attr = CRT_colors[PROCESS_MEGABYTES];
xSnprintf(buffer, n, "%4d ", (int)val);
}
} else {
*attr = CRT_colors[PROCESS_SHADOW];
xSnprintf(buffer, n, " N/A ");
}
}
void Process_writeField(const Process* this, RichString* str, ProcessField field) {
char buffer[256];
size_t n = sizeof(buffer);
@ -821,34 +847,13 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
xSnprintf(buffer, n, "%4ld ", this->nlwp);
break;
case PERCENT_CPU:
case PERCENT_CPU: Process_printPercentage(this->percent_cpu, buffer, n, &attr); break;
case PERCENT_NORM_CPU: {
float cpuPercentage = this->percent_cpu;
if (field == PERCENT_NORM_CPU) {
cpuPercentage /= this->processList->activeCPUs;
}
if (cpuPercentage > 999.9F) {
xSnprintf(buffer, n, "%4u ", (unsigned int)cpuPercentage);
} else if (cpuPercentage > 99.9F) {
xSnprintf(buffer, n, "%3u. ", (unsigned int)cpuPercentage);
} else {
if (cpuPercentage < 0.05F)
attr = CRT_colors[PROCESS_SHADOW];
xSnprintf(buffer, n, "%4.1f ", cpuPercentage);
}
float cpuPercentage = this->percent_cpu / this->processList->activeCPUs;
Process_printPercentage(cpuPercentage, buffer, n, &attr);
break;
}
case PERCENT_MEM:
if (this->percent_mem > 99.9F) {
xSnprintf(buffer, n, "100. ");
} else {
if (this->percent_mem < 0.05F)
attr = CRT_colors[PROCESS_SHADOW];
xSnprintf(buffer, n, "%4.1f ", this->percent_mem);
}
break;
case PERCENT_MEM: Process_printPercentage(this->percent_mem, buffer, n, &attr); break;
case PGRP: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pgrp); break;
case PID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->pid); break;
case PPID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, this->ppid); break;
@ -864,8 +869,12 @@ void Process_writeField(const Process* this, RichString* str, ProcessField field
case STATE:
xSnprintf(buffer, n, "%c ", this->state);
switch (this->state) {
#ifdef HTOP_NETBSD
case 'P':
#else
case 'R':
attr = CRT_colors[PROCESS_R_STATE];
#endif
attr = CRT_colors[PROCESS_RUN_STATE];
break;
case 'D':
attr = CRT_colors[PROCESS_D_STATE];

View File

@ -4,7 +4,7 @@
htop - Process.h
(C) 2004-2015 Hisham H. Muhammad
(C) 2020 Red Hat, Inc. All Rights Reserved.
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -79,8 +79,6 @@ typedef struct ProcessMergedCommand_ {
char* str; /* merged Command string */
size_t highlightCount; /* how many portions of cmdline to highlight */
ProcessCmdlineHighlight highlights[8]; /* which portions of cmdline to highlight */
bool separateComm : 1; /* whether comm is a separate field */
bool unmatchedExe : 1; /* whether exe matched with cmdline */
bool cmdlineChanged : 1; /* whether cmdline changed */
bool exeChanged : 1; /* whether exe changed */
bool commChanged : 1; /* whether comm changed */
@ -358,6 +356,8 @@ void Process_fillStarttimeBuffer(Process* this);
void Process_printLeftAlignedField(RichString* str, int attr, const char* content, unsigned int width);
void Process_printPercentage(float val, char* buffer, int n, int* attr);
void Process_display(const Object* cast, RichString* out);
void Process_done(Process* this);

View File

@ -1,7 +1,7 @@
/*
htop - ProcessList.c
(C) 2004,2005 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - ProcessList.h
(C) 2004,2005 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - ProcessLocksScreen.c
(C) 2020 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - ProcessLocksScreen.h
(C) 2020 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - RichString.h
(C) 2004,2011 Hisham H. Muhammad
Released under the GNU GPL, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

112
README
View File

@ -1,10 +1,12 @@
# [![htop](htop.png)](https://htop.dev)
# [![htop logo](htop.png)](https://htop.dev)
[![CI](https://github.com/htop-dev/htop/workflows/CI/badge.svg)](https://github.com/htop-dev/htop/actions)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/21665/badge.svg)](https://scan.coverity.com/projects/21665)
[![Mailing List](https://img.shields.io/badge/Mailing%20List-htop-blue.svg)](https://groups.io/g/htop)
[![IRC #htop](https://img.shields.io/badge/IRC-htop-blue.svg)](https://web.libera.chat/#htop)
[![Github Release](https://img.shields.io/github/release/htop-dev/htop.svg)](https://github.com/htop-dev/htop/releases/latest)
[![GitHub Release](https://img.shields.io/github/release/htop-dev/htop.svg)](https://github.com/htop-dev/htop/releases/latest)
[![Packaging status](https://repology.org/badge/tiny-repos/htop.svg)](https://repology.org/project/htop/versions)
[![License: GPL v2+](https://img.shields.io/badge/License-GPL%20v2+-blue.svg)](COPYING?raw=true)
![Screenshot of htop](docs/images/screenshot.png?raw=true)
@ -13,26 +15,30 @@
`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.
Also system wide information, like load average or swap usage, is shown.
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*).
Running `htop` requires `ncurses` libraries, typically named libncurses(w).
For more information and details on how to contribute to `htop` visit [htop.dev](https://htop.dev).
`htop` is written in C.
For more information and details visit [htop.dev](https://htop.dev).
## Build instructions
### Prerequisite
List of build-time dependencies:
* `build-essential` standard GNU autotools-based
* `autoconf`
* `autotools`
* standard GNU autotools-based C toolchain
- C99 compliant compiler
- `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:
> `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.
>
@ -41,28 +47,27 @@ List of build-time dependencies:
List of additional build-time dependencies (based on feature flags):
* `sensors`
* `hwloc`
* `libcap`
* `libcap` (v2.21 or later)
* `libnl-3`
Compiling `htop` requires the header files for `ncurses` . Install these and other required packages for C development from your package manager.
Install these and other required packages for C development from your package manager.
**Debian/Ubuntu**
~~~ shell
sudo apt install libncursesw5-dev autotools-dev autoconf
sudo apt install libncursesw5-dev autotools-dev autoconf build-essential
~~~
**Fedora/RHEL**
~~~ shell
sudo dnf install ncurses-devel automake autoconf
sudo dnf install ncurses-devel automake autoconf gcc
~~~
### Compiling from source:
To compile from sources downloaded from the Git repository (`git clone` or downloads from [Github releases](https://github.com/htop-dev/htop/releases/)), then run:
### Compile from source:
To compile from source, download from the Git repository (`git clone` or downloads from [GitHub releases](https://github.com/htop-dev/htop/releases/)), then run:
~~~ shell
./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`.
@ -74,52 +79,55 @@ To install on the local system run `make install`. By default `make install` ins
* `--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*
- dependency: *libncursesw*
- default: *yes*
* `--enable-affinity`:
enable `sched_setaffinity(2)` and `sched_getaffinity(2)` for affinity support; conflicts with hwloc
default: *check*
- default: *check*
* `--enable-hwloc`:
enable hwloc support for CPU affinity; disables affinity support
dependency: *libhwloc*
default: *no*
- dependency: *libhwloc*
- default: *no*
* `--enable-static`:
build a static htop binary; hwloc and delay accounting are not supported
default: *no*
- default: *no*
* `--enable-debug`:
Enable asserts and internal sanity checks; implies a performance penalty
default: *no*
- default: *no*
#### Performance Co-Pilot
* `--enable-pcp`:
enable Performance Co-Pilot support via a new pcp-htop utility
- dependency: *libpcp*
- 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*
- 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*
- dependency: *libcap*
- default: *check*
* `--with-proc`:
location of a Linux-compatible proc filesystem
default: */proc*
- default: */proc*
* `--enable-openvz`:
enable OpenVZ support
default: *no*
- default: *no*
* `--enable-vserver`:
enable VServer support
default: *no*
- default: *no*
* `--enable-ancient-vserver`:
enable ancient VServer support (implies `--enable-vserver`)
default: *no*
- default: *no*
* `--enable-delayacct`:
enable Linux delay accounting support
dependencies: *pkg-config*(build-time), *libnl-3* and *libnl-genl-3*
default: *check*
- dependencies: *pkg-config*(build-time), *libnl-3* and *libnl-genl-3*
- default: *check*
## Runtime dependencies:
@ -128,40 +136,42 @@ To install on the local system run `make install`. By default `make install` ins
### 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`.
#### Linux
* `libdl`, if not building a static binary, is always required when support for optional dependencies (i.e. `libsensors`, `libsystemd`) is present.
* `libcap`, user-space interfaces to POSIX 1003.1e capabilities, 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.
* `libsystemd` is optional when `--enable-static` was not used to configure `htop`. 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.
`htop` checks for the availability of the actual runtime libraries as `htop` runs.
**BSD**
On most *BSD systems you also have `kvm` as a static requirement to read all the kernel information.
#### BSD
On most BSD systems `kvm` is a requirement to read kernel information.
More information on required and optional dependencies can be found in [configure.ac](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.
See the manual page (`man htop`) or the help menu (**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.
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](https://htop.dev/mailinglist.html). Feel free to subscribe for release announcements or asking questions on the development of htop.
We have a [development mailing list](https://htop.dev/mailinglist.html). 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.
You can also join our IRC channel [#htop on Libera.Chat](https://web.libera.chat/#htop) 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](https://github.com/htop-dev/htop/issues).
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.
If you have found an issue within the source of `htop`, please check whether this has already been reported in our [GitHub issue tracker](https://github.com/htop-dev/htop/issues).
If not, please file a new issue describing the problem you have found, the potential location in the source code you are referring to and a possible fix if available.
## History
`htop` was invented, developed and maintained by Hisham Muhammad from 2004 to 2019. His [legacy repository](https://github.com/hishamhm/htop/) has been archived to preserve the history.
`htop` was invented, developed and maintained by [Hisham Muhammad](https://hisham.hm/) from 2004 to 2019. His [legacy repository](https://github.com/hishamhm/htop/) has been archived to preserve the history.
In 2020 a [team](https://github.com/orgs/htop-dev/people) took over the development amicably and continues to maintain `htop` collaboratively.
## License
GNU General Public License, version 2 (GPL-2.0)
GNU General Public License, version 2 (GPL-2.0) or, at your option, any later version.

View File

@ -1,7 +1,7 @@
/*
htop - RichString.c
(C) 2004,2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - RichString.h
(C) 2004,2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - ScreenManager.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - ScreenManager.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - Settings.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -28,11 +28,7 @@ void Settings_delete(Settings* this) {
free(this->filename);
free(this->fields);
for (unsigned int i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) {
if (this->hColumns[i].names) {
for (uint8_t j = 0; j < this->hColumns[i].len; j++)
free(this->hColumns[i].names[j]);
free(this->hColumns[i].names);
}
String_freeArray(this->hColumns[i].names);
free(this->hColumns[i].modes);
}
free(this->hColumns);
@ -65,16 +61,51 @@ static void Settings_readMeterModes(Settings* this, const char* line, unsigned i
this->hColumns[column].modes = modes;
}
static bool Settings_validateMeters(Settings* this) {
const size_t colCount = HeaderLayout_getColumns(this->hLayout);
for (size_t column = 0; column < colCount; column++) {
char** names = this->hColumns[column].names;
const int* modes = this->hColumns[column].modes;
const size_t len = this->hColumns[column].len;
if (!names || !modes || !len)
return false;
// Check for each mode there is an entry with a non-NULL name
for (size_t meterIdx = 0; meterIdx < len; meterIdx++)
if (!names[meterIdx])
return false;
if (names[len])
return false;
}
return true;
}
static void Settings_defaultMeters(Settings* this, unsigned int initialCpuCount) {
int sizes[] = { 3, 3 };
if (initialCpuCount > 4 && initialCpuCount <= 128) {
sizes[1]++;
}
for (int i = 0; i < 2; i++) {
// Release any previously allocated memory
for (size_t i = 0; i < HeaderLayout_getColumns(this->hLayout); i++) {
String_freeArray(this->hColumns[i].names);
free(this->hColumns[i].modes);
}
free(this->hColumns);
this->hLayout = HF_TWO_50_50;
this->hColumns = xCalloc(HeaderLayout_getColumns(this->hLayout), sizeof(MeterColumnSetting));
for (size_t i = 0; i < 2; i++) {
this->hColumns[i].names = xCalloc(sizes[i] + 1, sizeof(char*));
this->hColumns[i].modes = xCalloc(sizes[i], sizeof(int));
this->hColumns[i].len = sizes[i];
}
int r = 0;
if (initialCpuCount > 128) {
@ -134,8 +165,9 @@ static void Settings_readFields(Settings* settings, const char* line) {
}
// Dynamically-defined columns are always stored by-name.
char* end, dynamic[32] = {0};
char dynamic[32] = {0};
if (sscanf(ids[i], "Dynamic(%30s)", dynamic)) {
char* end;
if ((end = strrchr(dynamic, ')')) == NULL)
continue;
*end = '\0';
@ -180,8 +212,11 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
this->config_version = atoi(option[1]);
if (this->config_version > CONFIG_READER_MIN_VERSION) {
// the version of the config file on disk is newer than what we can read
fprintf(stderr, "WARNING: %s specifies configuration format version v%d, but this %s binary supports up to v%d.", fileName, this->config_version, PACKAGE, CONFIG_READER_MIN_VERSION);
fprintf(stderr, " The configuration version will be downgraded to v%d when %s exits.\n", CONFIG_READER_MIN_VERSION, PACKAGE);
fprintf(stderr, "WARNING: %s specifies configuration format\n", fileName);
fprintf(stderr, " version v%d, but this %s binary only supports up to version v%d.\n", this->config_version, PACKAGE, CONFIG_READER_MIN_VERSION);
fprintf(stderr, " The configuration file will be downgraded to v%d when %s exits.\n", CONFIG_READER_MIN_VERSION, PACKAGE);
String_freeArray(option);
fclose(fd);
return false;
}
} else if (String_eq(option[0], "fields")) {
@ -301,7 +336,7 @@ static bool Settings_read(Settings* this, const char* fileName, unsigned int ini
String_freeArray(option);
}
fclose(fd);
if (!didReadMeters) {
if (!didReadMeters || !Settings_validateMeters(this)) {
Settings_defaultMeters(this, initialCpuCount);
}
return didReadAny;
@ -325,7 +360,7 @@ static void writeFields(FILE* fd, const ProcessField* fields, Hashtable* columns
static void writeMeters(const Settings* this, FILE* fd, char separator, unsigned int column) {
const char* sep = "";
for (uint8_t i = 0; i < this->hColumns[column].len; i++) {
for (size_t i = 0; i < this->hColumns[column].len; i++) {
fprintf(fd, "%s%s", sep, this->hColumns[column].names[i]);
sep = " ";
}
@ -334,7 +369,7 @@ static void writeMeters(const Settings* this, FILE* fd, char separator, unsigned
static void writeMeterModes(const Settings* this, FILE* fd, char separator, unsigned int column) {
const char* sep = "";
for (uint8_t i = 0; i < this->hColumns[column].len; i++) {
for (size_t i = 0; i < this->hColumns[column].len; i++) {
fprintf(fd, "%s%d", sep, this->hColumns[column].modes[i]);
sep = " ";
}
@ -355,9 +390,9 @@ int Settings_write(const Settings* this, bool onCrash) {
}
#define printSettingInteger(setting_, value_) \
fprintf(fd, setting_ "=%d%c", (int) value_, separator);
fprintf(fd, setting_ "=%d%c", (int) (value_), separator)
#define printSettingString(setting_, value_) \
fprintf(fd, setting_ "=%s%c", value_, separator);
fprintf(fd, setting_ "=%s%c", value_, separator)
if (!onCrash) {
fprintf(fd, "# Beware! This file is rewritten by htop when settings are changed in the interface.\n");
@ -539,7 +574,10 @@ Settings* Settings_new(unsigned int initialCpuCount, Hashtable* dynamicColumns)
}
if (!ok) {
this->changed = true;
Settings_read(this, SYSCONFDIR "/htoprc", initialCpuCount);
ok = Settings_read(this, SYSCONFDIR "/htoprc", initialCpuCount);
}
if (!ok) {
Settings_defaultMeters(this, initialCpuCount);
}
return this;
}
@ -580,7 +618,7 @@ void Settings_setHeaderLayout(Settings* this, HeaderLayout hLayout) {
} else if (newColumns < oldColumns) {
for (unsigned int i = newColumns; i < oldColumns; i++) {
if (this->hColumns[i].names) {
for (uint8_t j = 0; j < this->hColumns[i].len; j++)
for (size_t j = 0; j < this->hColumns[i].len; j++)
free(this->hColumns[i].names[j]);
free(this->hColumns[i].names);
}

View File

@ -3,7 +3,7 @@
/*
htop - Settings.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
@ -22,7 +22,7 @@ in the source distribution for its full text.
#define CONFIG_READER_MIN_VERSION 2
typedef struct {
uint8_t len;
size_t len;
char** names;
int* modes;
} MeterColumnSetting;

View File

@ -1,7 +1,7 @@
/*
htop - SignalsPanel.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - SignalsPanel.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - SwapMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - SwapMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -1,7 +1,7 @@
/*
htop - SysArchMeter.c
(C) 2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - SysArchMeter.h
(C) 2021 htop dev team
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/
#include "Meter.h"

View File

@ -1,7 +1,7 @@
/*
htop - TasksMeter.c
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

View File

@ -3,7 +3,7 @@
/*
htop - TasksMeter.h
(C) 2004-2011 Hisham H. Muhammad
Released under the GNU GPLv2, see the COPYING file
Released under the GNU GPLv2+, see the COPYING file
in the source distribution for its full text.
*/

Some files were not shown because too many files have changed in this diff Show More