summaryrefslogtreecommitdiffstats
path: root/CRT.c
Commit message (Collapse)AuthorAgeFilesLines
* Avoid fprintf in signal handlersChristian Göttsche2024-04-131-18/+30
| | | | | | | fprintf(3) is not safe to call ins signal handlers due to file buffering and memory allocations. Format messages in signal handlers via snprintf(3) and output them via write(2).
* CRT: handle (ignore) signals `USR1` and `USR2`Christian Hesse2024-03-271-0/+4
| | | | These should not kill the application.
* Linux: add GPU meter and process columnChristian Göttsche2024-03-271-0/+30
| | | | | | | Based on the DRM client usage stats[1] add statistics for GPU time spend and percentage utilization. [1]: https://www.kernel.org/doc/html/latest/gpu/drm-usage-stats.html
* Ignore FOCUS_IN and FOCUS_OUT events if these have been activated within xtermDaniel Lange2024-03-141-0/+2
| | | | Closes: #1410
* CRT: print message with pending changes onlyChristian Hesse2024-01-151-0/+3
|
* CRT: print a warning when exiting on signalChristian Hesse2024-01-151-1/+9
| | | | | | | | Every now and then users complain about settings to being persisted. Most of the time this turns out to be caused by user: Exiting with signal causes htop not to save settings to htoprc. Make htop print a warning when exiting on signal.
* Minor code simplificationBenny Baumann2023-12-261-3/+1
|
* Fix code styleBenny Baumann2023-12-261-2/+2
|
* Proper check for signal framesBenny Baumann2023-10-301-4/+3
|
* default color preset: use bold blue for better visibilityChristian Hesse2023-06-201-1/+1
| | | | | This one for compressed zram was missing in 2ca75625ee5c2ac0ef1571e6918d7c94f3aa011c... Let's add it.
* Logic to retain screen and other changesSahil Siddiq2023-05-221-1/+19
| | | | | * Retain htop screen after quitting * Pass additional flag to CRT_init()
* {Memory,Swap}Meter: add "compressed memory" metricsIvan Shapovalov2023-04-231-0/+12
| | | | | | | | For now, the semantics are mostly fit for Linux zswap subsystem. For instance, we add the third swap usage metric that indicates the amount of memory that is accounted to swap but in fact stored elsewhere. This exactly matches the definition of frontswap/zswap, and is probably of little use to all other platforms.
* ZramMeter: update bar modeChristian Göttsche2023-04-111-6/+12
| | | | | | Show both compressed and uncompressed bars. Closes: #1216
* Correct some inconsistent function call conventions in CRT.cNathan Scott2023-04-061-16/+16
|
* Refactor to use a program name pointer instead of PACKAGE macroNathan Scott2023-04-061-8/+12
| | | | | | | | During SEGV handling under pcp-htop several incorrect strings were observed - in particular reporting htop as the binary name instead of pcp-htop. This is something we want to be crystal clear on when we request user stack traces etc, so make sure this cannot be done incorrectly.
* Create new File Descriptor meterBenny Baumann2023-02-191-0/+12
|
* Linux: highlight username if process has elevated privilegesChristian Göttsche2023-02-051-0/+6
| | | | | | Highlight processes started from binaries with file capabilities set, like kwin_wayland, or retaining Linux capabilities, via the ambient set, after switching from the root user, e.g. rtkit.
* Unwind: use arch generic assignmentChristian Göttsche2022-12-161-1/+1
| | | | | | | | | | The unw_proc_info_t member unwind_info might be of different type depending on the architecture. ../../CRT.c: In function ‘print_backtrace’: ../../CRT.c:1099:23: error: assignment to ‘unw_word_t’ {aka ‘long unsigned int’} from ‘void *’ makes integer from pointer without a cast [-Werror=int-conversion] 1099 | pip.unwind_info = NULL; | ^
* default color preset: use bold blue for better visibilityChristian Hesse2022-12-061-8/+8
| | | | | | | | | | The default color preset works fine on dark background, with one exception: blue characters are hardly readable. So let's make (most of) these bold. Even bold blue is fine on light background, so this sould not make anything worse. Closes #1023 (partial merge)
* Reformat code baseBenny Baumann2022-10-241-20/+20
| | | | | | | | | | | | | | This includes: - Wrap function implementations - Pointer alignment for function signatures - Pointer alignment for variable declarations - Whitespace after keywords - Whitespace after comma - Whitespace around initializers - Whitespace around operators - Code indentation - Line break for single line statements - Misleading alignment
* Display failures from initscrChristian Göttsche2022-08-221-2/+1
| | | | | | | | initscr(3) might fail, e.g. if the environment variable TERM is not set, and directly exit the program. Thus redirect stderr afterwards to not hide those potential fatal failure messages: Error opening terminal: unknown.
* Restore non mouse supportChristian Göttsche2022-08-101-2/+2
| | | | Closes: #1061
* Please Clang 15Christian Göttsche2022-08-091-4/+4
| | | | | | | CRT.c:1015:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes] void CRT_done() { ^ void
* Write full bufferChristian Göttsche2022-06-281-1/+1
| | | | Retry writing after a short write.
* Prevent null pointer dereference on early errorTobias Stoeckmann2022-06-031-2/+4
| | | | | | | | | | | | | | | | If a fatal error occurs before CRT_init has been called, CRT_done dereferences NULL in CRT_colors. Simply check if CRT_crashSettings is not NULL, which is eventually set when CRT_init has been called. If it is not set, then do not try to disable ncurses. Proof of Concept (on Linux): $ ./configure --with-proc=/var/empty $ make $ ./htop
* Call mousemask(3X) to truly enable or disable mouse controlWHR2022-05-191-7/+15
|
* Always set SIGCHLD to default handlingTobias Stoeckmann2022-01-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | The parent process of htop might have set SIGCHLD to ignore, which can be inherited by htop (Linux does this, OpenBSD resets to default). If SIGCHLD is ignored then waitpid returns -1 which is not properly handled by htop for lsof output. Proof of Concept (Linux): #include <signal.h> #include <unistd.h> int main(void) { char *arg[] = { "htop", NULL }; signal(SIGCHLD, SIG_IGN); execv("htop", arg); return 1; } If you run htop with ignored SIGCHLD then pressing "l" always fails, i.e. it is not possible to list open files even if lsof is installed.
* CRT: add debug printing functionChristian Göttsche2021-12-081-0/+11
|
* Introduce screen tabsHisham Muhammad2021-12-071-2/+34
| | | | This is a forward port (by nathans) of Hisham's original code.
* Fix issue where last line is not cleared when SIGINT is receivedEmmanuel Mathi-Amorim2021-12-011-0/+5
| | | | | | | | | | When we close the application using the quit function F10, the last line is cleared so that on terminals which do not support ALTBUF the last line is not clobbered. This do not happen when the application exits as a result of a signal (SIGINT,SIGTERM,SIGQUIT). Move the logic to clear the last line into the CRT_done function. This ensures that it will be executed when the CRT_handleSIGTERM is called.
* Update license headers to explicitly say GPLv2+Daniel Lange2021-09-221-1/+1
|
* Use libunwind for printing backtraceChristian Göttsche2021-09-211-9/+68
|
* CRT: close backup stderr file after resetChristian Göttsche2021-09-101-0/+2
| | | | | Close the backup file descriptor of original stderr once it has been restored at stderr.
* NetBSD: silence dropping const qualifier on define_key(3)Christian Göttsche2021-09-031-0/+8
| | | | | | On NetBSD define_key(3) has the prototype int define_key(char *sequence, int key_symbol);
* NetBSD: color process state P as runningChristian Göttsche2021-09-031-6/+6
| | | | | | On NetBSD state 'R' means runnable not running. Improve the color identifier name accordingly.
* Shorten crash output to fit on screenChristian Göttsche2021-08-261-16/+9
|
* IWYU updateChristian Göttsche2021-08-251-0/+1
|
* Reset the signal handlers at program exitChristian Göttsche2021-08-161-15/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The signal handler will access the Settings struct, which gets freed at normal program finalization. When using leak sanitizers with ASAN_OPTIONS=abort_on_error=1, which runs after program termination, any leak causes SIGABRT to be raised, calling the crash handler, which will derefernce the freed Settings. ==44741==ERROR: AddressSanitizer: heap-use-after-free on address 0x60d000000080 at pc 0x0000005680df bp 0x7fffe335e960 sp 0x7fffe335e958 READ of size 8 at 0x60d000000080 thread T0 #0 0x5680de in Settings_write /home/christian/Coding/workspaces/htop/Settings.c:329:26 #1 0x4f77b7 in CRT_handleSIGSEGV /home/christian/Coding/workspaces/htop/CRT.c:1020:4 #2 0x7f8a1120c13f (/lib/x86_64-linux-gnu/libpthread.so.0+0x1413f) #3 0x7f8a11042ce0 in __libc_signal_restore_set signal/../sysdeps/unix/sysv/linux/internal-signals.h:86:3 #4 0x7f8a11042ce0 in raise signal/../sysdeps/unix/sysv/linux/raise.c:48:3 #5 0x7f8a1102c536 in abort stdlib/abort.c:79:7 #6 0x4c3db6 in __sanitizer::Abort() (/home/christian/Coding/workspaces/htop/htop+0x4c3db6) #7 0x4c2090 in __sanitizer::Die() (/home/christian/Coding/workspaces/htop/htop+0x4c2090) #8 0x4d0a17 in __lsan::HandleLeaks() (/home/christian/Coding/workspaces/htop/htop+0x4d0a17) #9 0x4cd950 in __lsan::DoLeakCheck() (/home/christian/Coding/workspaces/htop/htop+0x4cd950) #10 0x7f8a110454d6 in __run_exit_handlers stdlib/exit.c:108:8 #11 0x7f8a11045679 in exit stdlib/exit.c:139:3 #12 0x7f8a1102dd10 in __libc_start_main csu/../csu/libc-start.c:342:3 #13 0x428a19 in _start (/home/christian/Coding/workspaces/htop/htop+0x428a19) 0x60d000000080 is located 64 bytes inside of 144-byte region [0x60d000000040,0x60d0000000d0) freed by thread T0 here: #0 0x4a4f72 in free (/home/christian/Coding/workspaces/htop/htop+0x4a4f72) #1 0x566693 in Settings_delete /home/christian/Coding/workspaces/htop/Settings.c:32:4 #2 0x4ede10 in CommandLine_run /home/christian/Coding/workspaces/htop/CommandLine.c:393:4 #3 0x4d6f32 in main /home/christian/Coding/workspaces/htop/htop.c:15:11 #4 0x7f8a1102dd09 in __libc_start_main csu/../csu/libc-start.c:308:16 previously allocated by thread T0 here: #0 0x4a5372 in __interceptor_calloc (/home/christian/Coding/workspaces/htop/htop+0x4a5372) #1 0x57f61a in xCalloc /home/christian/Coding/workspaces/htop/XUtils.c:55:17 #2 0x5688a6 in Settings_new /home/christian/Coding/workspaces/htop/Settings.c:392:21 #3 0x4ecb57 in CommandLine_run /home/christian/Coding/workspaces/htop/CommandLine.c:303:25 #4 0x4d6f32 in main /home/christian/Coding/workspaces/htop/htop.c:15:11 #5 0x7f8a1102dd09 in __libc_start_main csu/../csu/libc-start.c:308:16 SUMMARY: AddressSanitizer: heap-use-after-free /home/christian/Coding/workspaces/htop/Settings.c:329:26 in Settings_write
* Correct grammatical error in crash informationChristian Göttsche2021-08-101-1/+1
| | | | Spotted by @natoscott
* netbsd: Support curses libraries without ncurses mouse supportnia2021-07-151-0/+4
| | | | | | | | | | | | This adds a configure check for the ncurses getmouse() function and disables mouse-related code paths when mouse support is not present in the curses library. This is necessary for stable versions of NetBSD's libcurses, the development version has stub mouse functions for compatibility with ncurses. Signed-off-by: Nia Alarie <nia@NetBSD.org>
* Pointer indication aligned to typenameBenny Baumann2021-07-151-1/+1
|
* Add SIGINT handlerBenny Baumann2021-07-131-0/+1
| | | | | | | This SIGINT handler is installed on top of an optional handler that some curses/ncurses implementations provide. This ensures the curser is properly reset when hitting Ctrl+C.
* Add a new DynamicMeter class for runtime Meter extensionNathan Scott2021-07-071-1/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is based on exploratory work by Sohaib Mohamed. The end goal is two-fold - to support addition of Meters we build via configuration files for both the PCP platform and for scripts ( https://github.com/htop-dev/htop/issues/526 ) Here, we focus on generic code and the PCP support. A new class DynamicMeter is introduced - it uses the special case 'param' field handling that previously was used only by the CPUMeter, such that every runtime-configured Meter is given a unique identifier. Unlike with the CPUMeter this is used internally only. When reading/writing to htoprc instead of CPU(N) - where N is an integer param (CPU number) - we use the string name for each meter. For example, if we have a configuration for a DynamicMeter for some Redis metrics, we might read and write "Dynamic(redis)". This identifier is subsequently matched (back) up to the configuration file so we're able to re-create arbitrary user configurations. The PCP platform configuration file format is fairly simple. We expand configs from several directories, including the users homedir alongside htoprc (below htop/meters/) and also /etc/pcp/htop/meters. The format will be described via a new pcp-htop(5) man page, but its basically ini-style and each Meter has one or more metric expressions associated, as well as specifications for labels, color and so on via a dot separated notation for individual metrics within the Meter. A few initial sample configuration files are provided below ./pcp/meters that give the general idea. The PCP "derived" metric specification - see pmRegisterDerived(3) - is used as the syntax for specifying metrics in PCP DynamicMeters.
* Use the PACKAGE macro rather than htop directly, for overridingNathan Scott2021-06-131-6/+6
| | | | | | Allow other projects (PCP) to be able to ship an htop binary which uses the custom name (pcp-htop) in several diagnostics so that its clear which (if any!) binary failed.
* Use STDERR_FILENO instead of magic numberChristian Göttsche2021-05-161-1/+1
|
* Print current settings on crashChristian Göttsche2021-05-161-0/+8
|
* Add read-only optionChristian Göttsche2021-04-141-0/+6
| | | | | Add command line option to disable all system and process changing features.
* TaskMeter: always show number of threadsChristian Göttsche2021-03-311-0/+6
| | | | | | | | | | | Always show the number of kernel and userland threads, even when they are disabled to not be shown in the process list. The data is already available and might improve understanding the system utilization. Use a shadow color in case the kind of thread is hidden, else the normal meter one.
* Use `#if defined()` syntax when `#elif defined()` is presentBenny Baumann2021-03-211-1/+1
| | | | | | | 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.
* Linux: individually show shared memoryChristian Göttsche2021-03-151-0/+6
| | | | | | | | Shmem: Total memory used by shared memory (shmem) and tmpfs Source: https://www.kernel.org/doc/Documentation/filesystems/proc.txt Closes: #556

© 2014-2024 Faster IT GmbH | imprint | privacy policy