Commit Graph

2323 Commits

Author SHA1 Message Date
Christian Göttsche 5ef3c26168 Drop always true condition
The variable 'dir' is checked in line 645:
    if (!dir)
        return AC_ERROR;
2021-03-24 19:36:34 +01:00
David Zarzycki 3e8da0fcb6 Add MEMORY_SHARED to help screen 2021-03-24 19:30:28 +01:00
Christian Göttsche a19b176099 Correct spelling in comment 2021-03-24 19:27:57 +01:00
Christian Göttsche 9c437ceb0c Drop unused attributes of actually used function parameters
These parameters were once unused, but not anymore.
2021-03-24 19:27:03 +01:00
Christian Göttsche 7b293dc3e2 Linux: fix --drop-capabilities
Do not return false (= argument not handled) when actually handled
2021-03-22 11:56:19 +01:00
Nathan Scott 6fd5b05151
Merge pull request #564 from natoscott/platform-options
Move libcap use to (Linux) platform-specific code
2021-03-22 17:25:01 +11:00
Nathan Scott 253ff23f9e Use a platform-specific routine for long option usage
Related to https://github.com/htop-dev/htop/pull/564
2021-03-22 17:16:40 +11:00
Nathan Scott d56d23d91a Each platform defines its own long opt macro, prefer printf
Follow up on the two items of feedback from cgzones review,
and resolve a build failure picked up by CI on Mac OS X.

Related to https://github.com/htop-dev/htop/pull/564
2021-03-22 17:16:40 +11:00
Nathan Scott 0ada9f325f Move libcap use to (Linux) platform-specific code
The libcap code is Linux-specific so move it all below
the linux/ platform subdirectory.  As this feature has
custom command-line long options I provide a mechanism
whereby each platform can add custom long options that
augment the main htop options.  We'll make use this of
this with the pcp/ platform in due course to implement
the --host and --archive options there.

Related to https://github.com/htop-dev/htop/pull/536
2021-03-22 17:16:40 +11:00
Benny Baumann 57e0ce7b4f Use `#if defined()` syntax when `#elif defined()` is present
This prefers the `#if defined()` syntax over the `#ifdef` variant
whenever there's also a `#elif defined()` clause, thus making the
multiple branching structure more obvious and the overall use
more consistent.
2021-03-21 21:49:04 +01:00
Daniel Lange 1cb3aee07a Merge branch 'cputemp' of cgzones/htop 2021-03-21 18:09:14 +01:00
Daniel Lange 6ea93fc6c0 Merge branch 'openbsd' of cgzones/htop 2021-03-21 17:48:41 +01:00
Daniel Lange 63019065dc Merge branch 'cpu_proc_stat' of cgzones/htop 2021-03-21 17:48:02 +01:00
Christian Göttsche e4e3f6c390 OpenBSD: update
* Set process data for:
    - minflt
    - majflt
    - processor
    - nlwp

* Drop unimplemented nlwp column

* Scan userland threads

* Mark a 'Thread is currently on a CPU.' with 'R', and processes
  'Currently runnable' with 'P', do confine with man:ps(1) and Linux.
  See https://man.openbsd.org/ps.1

* Show CPU frequency
2021-03-20 18:30:08 +01:00
Christian Göttsche 58ad020aca ProcessList: fix treeview on OpenBSD when hiding kernel threads
Currently the tree-view is empty on OpenBSD when kernel threads are
hidden, cause the kernel thread 'swapper' has pid 0 and gets treated as
root of the tree and parent of 'init'.

Do not build any tree with a pid 0 root node.
2021-03-20 18:30:08 +01:00
Christian Göttsche a11d01568c Use unsigned types for CPU counts and associated variables 2021-03-19 23:30:54 +01:00
Benny Baumann 70fecb4984 Use consistent style for include check 2021-03-19 22:39:06 +01:00
Christian Göttsche f46fcf094e Linux: Rework libsensors parsing
Do not read driver depended labels, just count the number of
temperatures given:

  on #CPU:
    platform temp = max cpu temp
    CPU temps = first to last
  on #CPU + 1:
    platform temp = first temp
    CPU temps = second to last
  on #CPU / 2:
    platform temp = max cpu temp
    CPU temps = first to last concat first to last
      (with SMT core x + cpu count is the logical core of the physical
      core x)
  on #CPU / 2 + 1:
    platform temp = first temp
    CPU temps = second to last concat second to last
      (with SMT core x + cpu count is the logical core of the physical
      core x)

Closes: #529
Closes: #538
2021-03-19 22:11:22 +01:00
Christian Göttsche 53bcc5cbff ci: drop hwloc from clang-analyzer build
The hwloc header generates lots of warnings:

  In file included from Action.c:10:
  In file included from ./Action.h:15:
  In file included from ./Header.h:10:
  In file included from ./Meter.h:18:
  In file included from ./ProcessList.h:25:
  In file included from /usr/include/hwloc.h:2371:
  /usr/include/hwloc/helper.h:481:5: warning: Value stored to 'state' is never read [deadcode.DeadStores]
      state = 3;
      ^       ~
  1 warning generated.
2021-03-19 22:07:47 +01:00
Christian Göttsche db042f259b ci: use focal list for llvm mirror
The llvm bionic packages depend on libffi6, which is not available in
focal.
2021-03-19 22:07:47 +01:00
Daniel Lange 9a893b9a07 Merge branch 'richstring_memset' of cgzones/htop 2021-03-19 09:58:04 +01:00
Daniel Lange 67b815a817 Merge branch 'shared_before_cached' of cgzones/htop 2021-03-19 09:49:36 +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
Nathan Scott 1ba3915f73
Merge pull request #565 from cgzones/ci_clang12
ci: use clang 12
2021-03-18 08:20:17 +11:00
Christian Göttsche 16243a4a7e Action: merge conditions 2021-03-17 17:53:23 +01:00
Christian Göttsche e942736267 LinuxProcessList: drop unnecessary parenthesis 2021-03-17 17:53:00 +01:00
Christian Göttsche 9f41dc3332 MemoryMeter: show shared memory before cached
Shared memory is less free-able than cached memory.

Show it beforehand.
2021-03-17 16:32:16 +01:00
Christian Göttsche 1e806f9899 RichString: do not unnecessarily clean whole buffer
The local stack buffer does not need to be cleaned to zeros when
  - just initialized, cause the length is set to 0 and the first
    character is set to '\0', so all printing functions will safely stop
  - no further used, i.e. the variable goes out of scope
2021-03-17 15:54:17 +01:00
Christian Göttsche ac27df373a ci: use clang 12
llvm 12 is stable enough to be used in the CI as compiler and static
analyzer.
2021-03-17 15:27:56 +01:00
Christian Göttsche d9f2eacbc5 Linux: individually show shared memory
Shmem: Total memory used by shared memory (shmem) and tmpfs

Source: https://www.kernel.org/doc/Documentation/filesystems/proc.txt

Closes: #556
2021-03-15 22:34:14 +01:00
Christian Göttsche a4173f5209 Improve process following
- stay in follow mode on sort inversion (I)
- stay in follow mode after viewing help screen (h)
- select parent process (where available) when having followed a thread
  and hiding these (H)

Closes: #560
2021-03-14 14:47:15 +01: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 23797e730e CPUMeter_init: compactify branches 2021-03-12 17:43:23 +01:00
Christian Göttsche 0cfc9b0980 LinuxProcessList: refactor /proc/stat parsing
Combine reading CPU count and CPU usage, only open the file once.
Do not separately initialize totalPeriod and totalTime, cause the value
0 is handled in Platform_setCPUValues().

Take the number of currently running process from the entry
procs_running in /proc/stat instead of counting all scanned process
with state 'R', to include hidden tasks, e.g. threads.
2021-03-12 17:31:45 +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 350b48e44c Meter: do not access RichString internals
Use a temporary local variable
2021-03-12 16:49:45 +01:00
Christian Göttsche c38819a675 Settings: mark non-modified pointer parameters const 2021-03-12 16:48:41 +01:00
Christian Göttsche d37d66bb3a InfoScreen/ProcessList: do not access Vector internals
Use wrapper function to encapsulate the Vector structure
2021-03-12 16:46:55 +01:00
Christian Göttsche 3f99c2de24 Process: do not access RichString internals
Use wrapper macro to encapsulate the RichString structure
2021-03-12 16:46:04 +01:00
Christian Göttsche bea7f8e7af Process_compare: reorder checks
Check for result being 0 first, before checking if the result might be
negated, so we do not need to negate 0.
2021-03-12 16:44:46 +01:00
Christian Göttsche 9adcd9051a Object: always include stdbool.h
The function Object_isA() returning bool is nowadays unconditional
2021-03-12 16:38:36 +01:00
Christian Göttsche 8ba4ef327e configure: use portable AND
man:test(1)
    NOTE: Binary -a and -o are inherently ambiguous.  Use 'test EXPR1 &&
    test EXPR2' or 'test EXPR1 || test EXPR2' instead.

Also fix indent
2021-03-12 16:37:17 +01:00
Nathan Scott 31e59cc60d Merge branch 'misc' of https://github.com/cgzones/htop into cgzones-misc 2021-03-05 13:38:19 +11:00
Christian Göttsche b862e36ee7 Separate data-update and drawing of header 2021-03-04 23:57:45 +01:00
Christian Göttsche 2d1042adb3 Save text buffer in Meter 2021-03-04 23:57:45 +01:00
Benny Baumann 23c5b9ce3c Ensure buffer for gethostname(2) is properly terminated 2021-03-04 23:42:24 +01:00
Daniel Lange c5770c26af Merge branch 'follow' of cgzones/htop
Closes #557
2021-03-04 07:41:14 +01:00
Nathan Scott 8c421d527b Resolve trailing-whitespace failure in CI (merge issue) 2021-03-04 15:16:32 +11:00
Nathan Scott adaf748ab6 Fix include file ordering of generic headers 2021-03-04 13:44:40 +11:00
Nathan Scott 61ef1134d9 Move generic (shared) code into its own sub-directory
Code that is shared across some (but not all) platforms
is moved into a 'generic' home. Makefile.am cleanups to
match plus some minor alphabetic reordering/formatting.

As discussed in https://github.com/htop-dev/htop/pull/553
2021-03-04 13:40:59 +11:00