Commit Graph

1899 Commits

Author SHA1 Message Date
Christian Göttsche ceee96dcba Do not try to set not owned capabilities
If the process has already less capabilities than we are trying to keep,
do not try to set them.
2021-01-13 22:12:06 +01:00
Christian Göttsche 5fde0e0127 RichString_appendChr: add parameter to set attributes
Allows to set attributes when padding process fields in non-wide ncurses
mode.

Closes: #475
2021-01-13 19:22:33 +01:00
Christian Göttsche 78b993dbb4 kfreeBSD: include config.h for _GNU_SOURCE (part 2)
strcasestr(3) is a GNU extension and when compiling freebsd/Platform.c
on kfreebsd for Debian <string.h> is included before we define
_GNU_SOURCE, so the function is not available.

In file included from ./Object.h:16,
                 from ./ListItem.h:12,
                 from ./Meter.h:16,
                 from ./Header.h:10,
                 from ./Action.h:15,
                 from freebsd/Platform.h:13,
                 from freebsd/Platform.c:8:
./XUtils.h: In function ‘String_contains_i’:
./XUtils.h:43:11: warning: implicit declaration of function ‘strcasestr’; did you mean ‘strcasecmp’? [-Wimplicit-function-declaration]
   43 |    return strcasestr(s1, s2) != NULL;
      |           ^~~~~~~~~~
      |           strcasecmp
./XUtils.h:43:30: warning: comparison between pointer and integer
   43 |    return strcasestr(s1, s2) != NULL;
      |                              ^~
In file included from ./Object.h:16,
                 from ./ProcessList.h:16,
                 from freebsd/FreeBSDProcessList.h:15,
                 from freebsd/FreeBSDProcessList.c:8:
./XUtils.h: In function ‘String_contains_i’:
./XUtils.h:43:11: warning: implicit declaration of function ‘strcasestr’; did you mean ‘strcasecmp’? [-Wimplicit-function-declaration]
   43 |    return strcasestr(s1, s2) != NULL;
      |           ^~~~~~~~~~
      |           strcasecmp
./XUtils.h:43:30: warning: comparison between pointer and integer
   43 |    return strcasestr(s1, s2) != NULL;
      |                              ^~
2021-01-12 19:05:46 +01:00
Christian Göttsche 47cebafd77 kfreeBSD: include config.h for _GNU_SOURCE
strcasestr(3) is a GNU extension and when compiling freebsd/Platform.c
on kfreebsd for Debian <string.h> is included before we define
_GNU_SOURCE, so the function is not available.

In file included from ./Object.h:16,
                 from ./ListItem.h:12,
                 from ./Meter.h:16,
                 from ./Header.h:10,
                 from ./Action.h:15,
                 from freebsd/Platform.h:13,
                 from freebsd/Platform.c:8:
./XUtils.h: In function ‘String_contains_i’:
./XUtils.h:43:11: warning: implicit declaration of function ‘strcasestr’; did you mean ‘strcasecmp’? [-Wimplicit-function-declaration]
   43 |    return strcasestr(s1, s2) != NULL;
      |           ^~~~~~~~~~
      |           strcasecmp
./XUtils.h:43:30: warning: comparison between pointer and integer
   43 |    return strcasestr(s1, s2) != NULL;
      |                              ^~
In file included from ./Object.h:16,
                 from ./ProcessList.h:16,
                 from freebsd/FreeBSDProcessList.h:15,
                 from freebsd/FreeBSDProcessList.c:8:
./XUtils.h: In function ‘String_contains_i’:
./XUtils.h:43:11: warning: implicit declaration of function ‘strcasestr’; did you mean ‘strcasecmp’? [-Wimplicit-function-declaration]
   43 |    return strcasestr(s1, s2) != NULL;
      |           ^~~~~~~~~~
      |           strcasecmp
./XUtils.h:43:30: warning: comparison between pointer and integer
   43 |    return strcasestr(s1, s2) != NULL;
      |                              ^~
2021-01-12 17:02:16 +01:00
Christian Göttsche 66dd77aa6b Hashtable: use appropriate return type for nextPrime
The return value is guaranteed to be smaller than SIZE_MAX, so return
size_t (matters on 32 bit architectures).
2021-01-12 16:37:43 +01:00
Christian Göttsche 2b62126aea Mark several non-modified pointer variables const 2021-01-11 23:47:00 +01:00
Christian Göttsche 960f52b783 SELinuxMeter: hardcode SELINUX_MAGIC value
Avoid <linux/magic.h> include, not found by musl-gcc.
The value of SELINUX_MAGIC should really never change.
2021-01-11 23:45:47 +01:00
Christian Göttsche e6d536dd3f Add compiler hints on memory allocating utility functions 2021-01-11 21:08:58 +01:00
David Zarzycki 37e186fd66 Linux: Add SwapCached to the swap meter
According to the Linux kernel documentation, "SwapCached" tracks "memory
that once was swapped out, is swapped back in but still also is
in the swapfile (if memory is needed it doesn't need to be swapped out
AGAIN because it is already in the swapfile. This saves I/O)."
2021-01-11 20:27:47 +01:00
Christian Göttsche f4404effa4 Add option to drop Linux capabilities
Conflicts with setuid support, but that is commonly not enabled.
2021-01-11 20:19:51 +01:00
Christian Göttsche d72b0a682e Mark several non-modified pointer variables const 2021-01-11 20:12:34 +01:00
Christian Göttsche 1b2d48bc9a Remove dead code 2021-01-11 20:12:34 +01:00
Christian Göttsche d9240999e9 Process: drop commLen
It is only used on Linux to optimize memory handling in case the command
changes to a smaller-or-equal string.

This "optimization" however causes more code bloat and maintenance cost
on string handling issues than it gains.
2021-01-11 20:12:34 +01:00
Christian Göttsche 70f48f1f44 Add wrapper function for free and strdup
Reduces code in callers and helps avoiding memory leaks.
2021-01-11 20:12:34 +01:00
Christian Göttsche 958112c5a3 Refactor setting filter and use safe strncpy 2021-01-11 20:12:34 +01:00
Christian Göttsche a118928dee XUtils: add safe strncpy implementation
The standard strncpy fails to null-terminate the destination in case
the source is longer than the passed size.
2021-01-11 20:12:34 +01:00
Christian Göttsche 3715301fe3 Drop always false condition
The previous if conditional branch would have been taken
in case this condition would be true,
2021-01-11 20:12:34 +01:00
Daniel Lange d53398fb48 Fix git log remainder in ChangeLog 2021-01-11 19:40:19 +01:00
Daniel Lange 58ce887d14 Update version number to 3.0.6-dev to identify git repo builds 2021-01-11 18:59:55 +01:00
Daniel Lange ce6d60e7de Release 3.0.5 2021-01-11 18:18:21 +01:00
Daniel Lange 5d92a9f20d Merge branch 'fix-palette2' of deviant/htop 2021-01-11 17:45:59 +01:00
Daniel Lange b3500ac3b7 Clarify that only the main screen function bar is optionally hidden 2021-01-11 13:50:34 +01:00
Daniel Lange 2ba8a81d47 Fix clearing the last line in setup on function bar change (thanks cgzones) 2021-01-11 13:47:33 +01:00
V f2f1c99ad9 Fix white text in the Light Terminal colour scheme 2021-01-11 12:54:19 +01:00
Daniel Lange 1ffe5d79bd Make Infoscreens the correct height 2021-01-11 12:53:07 +01:00
Daniel Lange 8502f4e64f Merge branch 'wide_proc_comm' of cgzones/htop 2021-01-11 12:43:39 +01:00
Christian Göttsche a5db139a0a Linux: use correct column alignment for wide fields
This affects:
- PROC_COMM, PROC_EXE and CWD on Linux
- JAIL on FreeBSD and DragonFlyBSD
- ZONE on Solaris
2021-01-11 12:02:25 +01:00
Daniel Lange 8a67d7f086 Merge branch 'RichString_attrn' of cgzones/htop 2021-01-11 09:36:42 +01:00
Daniel Lange 0b89c66f58 Merge branch 'following_exit' of cgzones/htop 2021-01-11 09:36:25 +01:00
Christian Göttsche 3bb731c645 RichString_setAttrn: refactor to take a length instead of a stop index
Fixes: #459
2021-01-10 16:51:25 +01:00
Christian Göttsche fbaa0cd146 Exit follow mode cleanly after followed process dies 2021-01-10 16:43:24 +01:00
Christian Göttsche a076488809 Solaris: make Process callbacks static
Fixes prototype of SolarisProcess_compareByKey since 90ea3ac3
2021-01-09 20:17:31 +01:00
Christian Göttsche 6301d5c1da Convert unnecessary static variables
They are not used in any other function and are not used maybe
uninitialized.
2021-01-09 14:31:07 +01:00
Daniel Lange 4979245aa5 Update help and man page for improved -t / -s options 2021-01-08 21:34:30 +01:00
Christian Göttsche 0155980fd6 Free memory on multiple filter command line arguments 2021-01-08 21:07:05 +01:00
Daniel Lange 2af90b711f Merge branch 'err_h' of cgzones/htop 2021-01-08 17:39:04 +01:00
Daniel Lange d55f394541 Merge branch 'light_color' of cgzones/htop 2021-01-08 17:35:26 +01:00
Daniel Lange c7d93a8f30 Merge branch 'ncurses_format' of cgzones/htop 2021-01-08 17:31:06 +01:00
Christian Göttsche 2d2a2df6f2 Refactor crash handler message to avoid embedded directive
CRT.c:821:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
#ifdef HAVE_EXECINFO_H
 ^
CRT.c:823:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
#endif
 ^
CRT.c:858:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
#ifdef HTOP_DARWIN
 ^
CRT.c:862:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
#endif
 ^

CRT.c:864:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
#ifdef HTOP_DARWIN
 ^
CRT.c:868:2: error: embedding a directive within macro arguments has undefined behavior [-Werror,-Wembedded-directive]
#endif
 ^
2021-01-08 16:53:16 +01:00
Christian Göttsche de645ea16c ci: enable format attributes in ncurses headers
Avoid format string issues like bfcb8ca0 by helping compilers spot such
bogus usages.

Also use LTO and O3 in the full-featured gcc job, which might trigger
additional warnings on advanced inlining, like
3695cbd5d8 and
ad3acfc847
2021-01-08 14:05:56 +01:00
Christian Göttsche 6ae56f2578 Revert color change on LightTerminal
Partially revert 4b14ab9789

ColorPair(Black,Black) is not actually black on black, but due to
adjustments in CRT_setColors() black on default-background-color.

Thanks to V for reporting.
2021-01-08 11:25:25 +01:00
V bfcb8ca019 InfoScreen: fix uncontrolled format string
mvwprintw takes a format string as its fourth argument, and title is
user-controlled. This results in e.g. crashing when trying to trace a
process with a format specifier in its command line.
2021-01-08 11:06:38 +01:00
Christian Göttsche d800d7a3ce Drop usage of formatted error messages from <err.h>
They do not clean up the ncurses environment, leaving the terminal in a
broken state.

Also drop bare usage of exit(3).
2021-01-07 16:10:05 +01:00
Christian Göttsche 27db9297b7 Show arrow indicating order of sorted process column 2021-01-07 14:46:44 +01:00
Christian Göttsche 330d4fe22f Unify prototype of Vector_get
Vector_get() currently takes a `const Vector*` in debug mode and a
`Vector*` else.
2021-01-06 17:14:06 +01:00
Christian Göttsche 8e10cde800 Hashtable: fail hard on too big size request 2021-01-06 16:59:28 +01:00
Christian Göttsche ca2c01bd16 Hashtable: widen size from int to size_t 2021-01-06 16:59:28 +01:00
Christian Göttsche 7043a93eba Hashtable: hide implementation of Hashtable and HashtableItem 2021-01-06 16:59:28 +01:00
Christian Göttsche 8fe04b7494 Hashtable: use more distinct typename for key type 2021-01-06 16:59:28 +01:00
Matej Dian 43d5c61884 LibSensors: add support for Ryzen CPUs 2021-01-06 16:54:59 +01:00