summaryrefslogtreecommitdiffstats
path: root/linux
Commit message (Collapse)AuthorAgeFilesLines
* Linux: reorder /proc/<pid>/status parsingChristian Göttsche27 hours1-26/+27
| | | | | | | | | | | | | When parsing an essential pid entry file like 'status' fails, we treat the process as a short-lived one and skip adding it into the process table. This should be done before the process is added, as the goto label used for error handling can free the process structure, thus causing an use-after-free scenario. Fixes: 22d25db46 ("Linux: detect container process by different PID namespace") Closes: #1455
* Linux: show newlines in commands as ? instead of spaceChristian Göttsche7 days1-0/+6
| | | | | | | | Since \n is used internally by htop to split command lines, replace \n with \r in command lines to not display them as space. Merging the command string will not work, but newlines in commands should be rather the exception.
* Linux: Permit non-ASCII for CGROUP, CONTAINER & SECATTR fieldsExplorer092024-04-261-4/+16
| | | | | | | | | | Assume the CGROUP, CCGROUP, CONTAINER and SECATTR field value may contain non-ASCII characters and use RichString_appendWide() to convert the strings. Patch suggested by Christian Göttsche (@cgzones) Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
* Merge branch 'gcc14-analyzer-fixes' of BenBE/htopDaniel Lange2024-04-181-1/+1
|\
| * Explicit memory initialization when reading status fileBenny Baumann2024-04-171-1/+1
| |
* | Use 'sb' name for local 'struct stat' buffersExplorer092024-04-171-13/+13
| | | | | | | | | | | | | | | | Deprecate the use of 'st' and other names. The 'sb' name is often seen in example codes in Linux man pages. (The 'statbuf' name is sometimes also used but I choose 'sb' name because it's shorter.) No code changes.
* | Use 'fp' name for local 'FILE*' variables.Explorer092024-04-172-34/+34
|/ | | | | | | | | | | It is inappropriate to use the 'fd' name for 'FILE*' variables. POSIX file descriptiors are of type 'int' and are distinguished from ISO C stream pointers (type 'FILE*'). Rename these variables to 'fp', which is a preferred naming in POSIX. (Note that ISO C preferred the 'stream' name for the variables.) No code changes.
* linux: harden terminal parsingChristian Göttsche2024-04-131-9/+33
| | | | | Handle corrupted data in /proc/tty/drivers, either via injection or buffer truncation.
* Work around GCC14 memleak diagnosticBenny Baumann2024-04-081-1/+1
| | | | | While both pointers are identical, GCC-14 with -fanalyzer complains about these return statements to leak memory. The leak is only reported with LTO though.
* Align parameter names in declarations with definitionsChristian Göttsche2024-04-081-1/+1
|
* Use uppercase floating point literalsChristian Göttsche2024-04-082-4/+4
|
* Drop casts to same typeChristian Göttsche2024-04-081-4/+4
|
* Linux: fix title alignments of GPU columnsChristian Göttsche2024-04-081-2/+2
| | | | | Percentage column was always broken, time column needs to be adjusted after recent formatting changes.
* Linux: add process column whether it is marked a container processChristian Göttsche2024-04-064-1/+19
| | | | | Might be useful for some users and for debugging the hideRunningInContainer detection.
* Linux: detect container process by different PID namespaceChristian Göttsche2024-04-061-13/+45
| | | | | | | Container engines like docker and podman rely on Linux namespaces. If available check if the target process is inside a different PID namespace than htop. This check will mark sandbox'ed applications, e.g. under bubblewrap, but not light-wight containers, like distrobox.
* Linux: do not always read /proc/<pid>/statusChristian Göttsche2024-04-061-2/+9
| | | | | | | | | #1211 showed reading /proc/<pid>/status might have a significant performance impact. Do not read by default only if actually needed, since the permitted capabilities are no longer gather from it. Improves: 8ea144df ("Linux: Refactor /proc/<pid>/status parsing") Improves: #1211
* Linux: reorder some calls in LinuxProcessList_recurseProcTree()Christian Göttsche2024-04-061-26/+34
| | | | | | Improve maintainability by reordering calls in LinuxProcessList_recurseProcTree() to group them by side-effect or interdependency.
* Linux: update gathering information regarding threadsChristian Göttsche2024-04-063-39/+153
| | | | | | | | | Document for each block gathering information about a task whether the information is shared for the whole process or specific to a single userland thread. Also avoid system calls for process-shared information and reuse the information from the main task.
* Linux: gather permitted capabilities via capget(2)Christian Göttsche2024-04-061-8/+15
| | | | | | | | | #1211 has shown reading /proc/<pid>/status might have a significant performance impact. It was started to be read by default to gather the permitted capabilities of the process. Gather permitted capabilities via the syscall capget(2) instead. cap_get_proc(3) is not used to avoid linking with -lcap.
* Adapt GPU_TIME field for the new nanoseconds formatExplorer092024-04-051-2/+2
| | | | Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
* linux: use dlopen for libnl3 instead of dynamic linkingChristian Göttsche2024-04-051-23/+136
| | | | | | | | | | | Instead of the current behavior of dynamic linking against libnl3 and libnl-genl-3 when configured with --enable-delayacct, load the shared libraries on request, if any delay accounting related process field is active, via dlopen(3), similar to libsensors and libsystemd. Distribution, who currently build htop with --enable-delayacct, need to explicitly add libnl3 and libnl-genl-3 as runtime dependencies to continue supporting delay accounting out-of-the-box.
* linux: move libnl code into separate fileChristian Göttsche2024-04-053-113/+147
| | | | | | | Move all the code using libnl functionality into a separate file to ease modifications. No functional change.
* Use size_t for array indices consistentlyBenny Baumann2024-04-051-5/+5
| | | | This avoids a compiler warning with GCC 14 and LTO claiming uninitialized use of data[i] in the last loop.
* Linux: Correctly mark trailing offline CPU threadsMartin Rys2024-03-271-7/+18
|
* Avoid glibc FILE API for number of open filesBenny Baumann2024-03-271-5/+5
|
* Avoid glibc FILE API for maxpidBenny Baumann2024-03-271-9/+15
|
* Avoid glibc FILE API for loadavgBenny Baumann2024-03-271-13/+14
|
* Avoid glibc FILE API for uptime readingBenny Baumann2024-03-271-7/+13
|
* Avoid glibc FILE API for secattrBenny Baumann2024-03-271-10/+4
|
* Avoid glibc FILE API for oom_scoreBenny Baumann2024-03-271-10/+15
|
* Avoid glibc FILE voodooBenny Baumann2024-03-271-4/+5
| | | | Addresses #1408
* Linux: scan GPU based on previous activityChristian Göttsche2024-03-272-6/+13
| | | | | | Instead of ignoring the standard file descriptors 0, 1 and 2 scan for GPU usage of a process only if that process had activity last cycle or its last scan was more than five seconds ago.
* Linux: add GPU meter and process columnChristian Göttsche2024-03-2711-2/+521
| | | | | | | 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
* Introduce autoTitleRightAlign column flagChristian Göttsche2024-03-271-1/+1
| | | | | | Instead of handling PERCENT_CPU as a special case for whether to align the title of a dynamically sized column to the right or the left introduce a new flag, which can be reused by other columns.
* Read executable name before checking the command lineBenny Baumann2024-01-271-39/+48
| | | | This potentially avoids guessing the right path in the presence of spaces inside the executable path.
* Properly track if we actually hit any token while scanning cmdlineBenny Baumann2024-01-271-49/+78
|
* Explicitly check sscanf(3) and fscanf(3) return valuesChristian Göttsche2024-01-253-12/+12
| | | | | | | | | Compare the return value of sscanf(3) and fscanf(3) explicitly against the expected number of parsed items and avoid implicit boolean conversion. Such an implicit conversion would treat EOF (-1) the same as at least one item parsed successfully. Reported by CodeQL.
* Linux: drop preconditions for free_and_xStrdup()Christian Göttsche2024-01-201-6/+0
| | | | | free_and_xStrdup() internally skips the strdup() allocation if both strings exist are are the same. Drop such conditions prior of a call.
* Linux: rename variable for clearer intentChristian Göttsche2024-01-201-2/+2
| | | | | | Make it more clear the variable stores the previous tty number (similar to lasttimes), while the current one gets set in the intermediate LinuxProcessTable_readStatFile().
* Fix the display of number of running tasksBenny Baumann2024-01-121-2/+1
| | | | | | This was broken by a logic change in 72235d8e. Fixes: #1369
* Fix static linking with libsystemdChristian Göttsche2024-01-101-0/+1
| | | | | | libsystemd requires libcap for static linking. Add missing macro for function alias.
* Linux: use fseek(3)Christian Göttsche2024-01-101-5/+2
| | | | Use fseek(3) instead of rewind(3) to check for success.
* Shorten docker container IDs to 12 charactersBenny Baumann2023-12-311-0/+35
|
* Relocate include of config.h from header to source modeuleBenny Baumann2023-12-266-8/+4
|
* Update includes based on IWYUBenny Baumann2023-12-2611-22/+29
|
* Use consistent style for process field output/compare functionsBenny Baumann2023-12-261-2/+5
|
* Fix code styleBenny Baumann2023-12-265-106/+107
|
* Add includes for config.h as per the discussion in PR #1337Daniel Lange2023-12-266-0/+12
| | | | | | Many thanks to @Explorer09 Kang-Che Sung (宋岡哲). Also add a #error stanza to XUtils.h in case somebody forgets the beautiful mess GNU forces on us.
* Consolidate duplicate string constants in CGroup filtersBenny Baumann2023-12-111-33/+22
|
* Add column for process container nameBenny Baumann2023-12-114-1/+29
|

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