Commit Graph

155 Commits

Author SHA1 Message Date
Nathan Scott 10b541b5e4
Update Settings_newScreen with single-line sortKey checking.
Co-authored-by: BenBE <BenBE@geshi.org>
2022-05-01 16:21:13 +10:00
Nathan Scott cde72dd0b0 Remove redundant null checks on Settings_write (covscan)
Coverity scan reports that there is dead code in Settings_write
checking for nulls that have already been dereferenced on every
code path leading to the check.  This is likely a hangover from
times when the screens pointer was only conditionally allocated
- they're not needed anymore.
2022-04-30 13:55:56 +10:00
Nathan Scott cb61865bb9 Add array bounds checking for the Process_fields array (covscan)
Coverity scan reports there may be a code path that would cause
an overrun in the (relatively new) ScreenSettings code where it
evaluates default sort direction.  Add bounds check and default
to descending instead of a potentially invalid array access.
2022-04-30 13:50:25 +10:00
Daniel Lange 0ffd772d28 Fix header layout and meters reset if a header column is empty
Closes #880
Patch from BenBE and cgzones
2022-04-02 12:30:30 +02:00
Christian Göttsche 5b78ad2d53 Set correct default sorting direction
Respect the field option defaultSortDesc for the default screen sort
direction, e.g. for CPU%.
2021-12-17 14:45:15 +01:00
Christian Göttsche 6fcb1994c8 Do not combine default and configuration process fields
When reading a configuration file with the syntax previous to the
screens update Settings_defaultScreens() will add the default fields and
later ScreenSettings_readFields() will add the ones from the
configuration file. This will duplicate some fields and corrupt the
columns due to the boundless Command field.
2021-12-17 14:45:15 +01:00
Christian Göttsche 6e9a5e9e49 Mark ScreenDefaults const 2021-12-17 14:45:15 +01:00
Christian Göttsche df1914f429 Add ScreenSettings_delete helper 2021-12-08 16:34:15 +01:00
Christian Göttsche 3cfdf66d9a Settings: initialize default sort key for new screenpanel
Use C99 struct initialization, which also makes using calloc redundant.

htop: Process.c:1179: int Process_compareByKey_Base(const Process *, const Process *, ProcessField): Assertion `0 && "Process_compareByKey_Base: default key reached"' failed.
2021-12-08 14:55:14 +01:00
Nathan Scott 0e58784224 Fix memory leak on shutdown in new screen settings code.
Also tidy up the calloc call parameters in the initial allocation
of this pointer, thanks to @BenBE for noticing.
2021-12-07 17:04:49 +11:00
Sohaib Mohamed ba3a1df806 Fix misc styleguide issues and add missing header files
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
2021-12-07 17:04:49 +11:00
Sohaib Mohamed b672e60886 Enable tabs for a fresh install of htop Only
If the new htop is configured with htoprc having no tabs (eg on upgrade)
then the interface will not automatically introduce/enable them.
However, for a fresh install of htop, enabling them automatically

Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
2021-12-07 17:04:49 +11:00
Sohaib Mohamed cd6457ef88 Fixup tabs with dynamic Columns - add missing `Dynamic()` 2021-12-07 17:04:49 +11:00
Nathan Scott cc2547fcf0 Improvements to the tab code after initial feedback 2021-12-07 17:04:49 +11:00
Hisham Muhammad 72ba20fa5f Introduce screen tabs
This is a forward port (by nathans) of Hisham's original code.
2021-12-07 17:04:49 +11:00
Benny Baumann 74afca7bc1 Validate meter configuration before proceeding 2021-10-06 08:59:02 +02:00
Benny Baumann 2a13e15ad0 Properly release memory on partially read configuration 2021-10-06 08:59:02 +02:00
Christian Göttsche 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
Nathan Scott 4c846921a6 Improve configuration file version diagnostic formatting slightly 2021-09-27 15:13:01 +10:00
Daniel Lange 94ad111391 Update license headers to explicitly say GPLv2+ 2021-09-22 14:28:19 +02:00
Christian Hesse 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
Nathan Scott c9b58c7fbe Add missing end-of-line to htoprc file version mismatch warning 2021-09-08 12:13:56 +10:00
Christian Göttsche 0925c54caa Drop redundant semicolons 2021-09-04 14:17:37 +02:00
Christian Göttsche b85b718e69 Settings: enclose casted macro argument in parenthesis 2021-09-04 09:48:53 +02:00
Christian Göttsche 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
Christian Göttsche 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
Nathan Scott 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
Christian Göttsche 4ed3ab5c2c Shorten crash output to fit on screen 2021-08-26 14:09:39 +02:00
Christian Göttsche 2bf626c4e4 IWYU update 2021-08-25 09:54:30 +02:00
Christian Göttsche db076b9c8e HeaderLayout: save name in configuration
Use a name in the user configuration file instead of the compile
time enum value, so that future reorderings or insertions do not change
the user selected layout.
2021-08-24 20:27:59 +02:00
Daniel Lange ec2307688e Merge branch 'header_fmt' of cgzones/htop 2021-08-23 14:56:05 +02:00
Daniel Lange 6d10736a64 Merge branch 'config_versions' of fasterit/htop 2021-08-23 14:53:24 +02:00
Daniel Lange 35d94a5ae5 Apply approved warning message suggested by nathans 2021-08-23 08:58:14 +02:00
Christian Göttsche 9060a4179d Add option to change Header layout 2021-08-22 16:15:59 +02:00
Daniel Lange a9ddaccc63 Merge branch 'read-settings-defaults' of bjpbakker/htop 2021-08-18 14:47:16 +02:00
Daniel Lange 4b59a2e6b7 Introduce versioned config files and config_reader_min_version 2021-08-13 23:21:54 +02:00
Sohaib Mohamed 6f2021f3d9 PCP: support for 'dynamic columns' added at runtime
Implements support for arbitrary Performance Co-Pilot
metrics with per-process instance domains to form new
htop columns.  The column-to-metric mappings are setup
using configuration files which will be documented via
man pages as part of a follow-up commit.

We provide an initial set of column configurations so
as to provide new capabilities to pcp-htop: including
configs for containers, open fd counts, scheduler run
queue time, tcp/udp bytes/calls sent/recv, delay acct,
virtual machine guests, detailed virtual memory, swap.

Note there is a change to the configuration file path
resolution algorithm introduced for 'dynamic meters'.
First, look in any custom PCP_HTOP_DIR location.  Then
iterate, in priority order, users home directory, then
local sysadmins files in /etc/pcp/htop, then readonly
configuration files below /usr/share/pcp/htop.  This
final location becomes the preferred place for our own
shipped meter and column files.

The Settings file (htoprc) writing code is updated to
not using the numeric identifier for dynamic columns.
The same strategy used for dynamic meters is used here
where we write Dynamic(name) so the name can be setup
once more at start.  Regular (static) columns writing
to htoprc - i.e. numerically indexed - is unchanged.
2021-08-13 07:32:57 +02:00
Bart Bakker c1c4b5a1ab
Read settings after applying defaults
Default settings are used as a base and only settings specified in `htoprc` are
applied on top of it. This patch removes the special case for applying some
defaults  when the config does not contain a `meters` key. All defauls are set
before any attempt to read settings, so only keys actually present in the config
file are overridden.
2021-08-02 17:33:34 +02:00
nia e8f27ebc26 Disable mouse option when support is unavailable 2021-07-15 19:09:08 +02:00
Benny Baumann 0d85af2872 Whitespace around operators 2021-07-15 06:57:24 +02:00
Benny Baumann bf07c713ba Allow for highlighting of deleted executables to be configured
Fixes #383
2021-05-23 09:30:36 +02:00
Christian Göttsche 1f5f40c091 Print current settings on crash 2021-05-16 19:55:31 +02:00
Christian Göttsche 36880cd61c Add read-only option
Add command line option to disable all system and process changing
features.
2021-04-14 17:21:43 +02:00
Christian Göttsche a11d01568c Use unsigned types for CPU counts and associated variables 2021-03-19 23:30:54 +01:00
Graham Inggs ee97916fd5
Merge pull request #436 from cgzones/freebsd
FreeBSD: add support for CPU frequency and temperature
Tested on two physical systems running FreeBSD 12.1
2021-03-18 14:03:51 +02:00
Christian Göttsche 1275139795 Settings_write: fix return value on error
Return a negative errno on fprintf() or flcose() failure, not a return
value of ferror() or flcose().
2021-03-13 18:15:20 +01:00
Christian Göttsche 521f1343e3 Settings: check if writing configuration file was successful
Writing to the file stream might fail due to a immutable file or a
filesystem error.
Check the error indicator for the stream and for fclose() failures.
2021-03-12 16:56:06 +01:00
Christian Göttsche c38819a675 Settings: mark non-modified pointer parameters const 2021-03-12 16:48:41 +01:00
Benny Baumann 82157f598e Refactor to remove no-op calls
This removes the call-sites of the removed setuid feature
2021-02-17 15:59:50 +01:00
Daniel Lange 2c6222e30a Option and key ("*") to collapse / expand all branches under PID 1
(and PID 2 if kernel threads are shown)

Based on hishamhm/htop#510 by Krishna Chaitanya, B
Closes #68
2021-02-13 16:47:04 +01:00