summaryrefslogtreecommitdiffstats
path: root/linux/LinuxProcessList.c
Commit message (Collapse)AuthorAgeFilesLines
* LinuxProcessList_recurseProcTree: keep on read errorDenis Lisov2022-05-051-1/+6
| | | | | | | | If a process goes away while reading its fields, but we already have that process in the list, we should keep it in case the "highlight dying processes" mode is active. Not only is that expected in this mode, but this should also ensure parents are in the list when their children are (wanted for tree mode consistency).
* LinuxProcessList_recurseProcTree: open dirfd firstDenis Lisov2022-05-051-8/+8
| | | | | | | | | | A process can die between reading the directory listing and opening the directory FD (if HAVE_OPENAT) or /proc files (otherwise) for reading the process data. This race would cause LinuxProcessList_recurseProcTree to remove it from the list immediately, which is unexpected in the "highlight dying processes" mode and can break the tree structure. This patch closes this race in the HAVE_OPENAT case by only accessing the process entry after the directory FD has been opened.
* Remove redundant sscanf calls (in (s)scanf a blank validates _zero_ or more ↵Daniel Lange2022-05-051-7/+2
| | | | | | | | whitespace) man sscanf(3): A sequence of white-space characters (space, tab, newline, etc.; see isspace(3)). This directive matches any amount of white space, including none, in the input.
* Fix typoChristian Göttsche2022-04-301-4/+4
|
* use xCalloc for allocating cpuDataer-azh2022-03-271-1/+1
|
* Linux: allocate cpuData before reading cpu count.er-azh2022-03-261-3/+10
|
* Linux: fix crash in LXDer-azh2022-03-261-1/+1
|
* Auto-size (normalized) CPU usage columnsBenny Baumann2022-03-061-0/+1
|
* Linux: dynamically adjust column width of CGROUP C(ompressed)CGROUPChristian Göttsche2022-03-061-1/+12
|
* Linux: dynamically adjust the SECATTR column widthChristian Göttsche2022-03-061-0/+3
| | | | | | | | SELinux contexts can be quite long; adjust the column width dynamically at each cycle to the longest value. Also with the recent addition of multiple screens, over-long columns can be moved into their own screen.
* Fix division by zero when calculating IO ratesBenny Baumann2022-02-031-2/+4
| | | | Fixes #935
* LinuxProcessList: do not collect LRS per threadDenis Lisov2021-12-181-2/+4
| | | | | It's a memory map property, so it's process-wide and collecting it just once should be enough.
* Introduce screen tabsHisham Muhammad2021-12-071-15/+16
| | | | This is a forward port (by nathans) of Hisham's original code.
* Extract string writing/buffer handling into some callbackBenny Baumann2021-11-281-3/+3
|
* Compress cgroup names based on some heuristicsBenny Baumann2021-11-281-0/+20
|
* Filter leading colons in CGROUP nameBenny Baumann2021-11-281-3/+10
|
* Linux: use proper way to detect kernel threadsRin Cat (鈴猫)2021-11-091-15/+20
| | | | | | Use PF_KTHREAD flag in /proc/[pid]/stat to detect kernel threads. This fixed an issue when a process's cmdline is empty, htop think it is a kernel thread.
* Tidy up process state handlingmarcluque2021-11-021-4/+20
|
* Linux: ignore mapped /dev/zeroChristian Hesse2021-10-251-0/+5
| | | | | Virtualbox maps /dev/zero for memory allocation. That results in false positive, so ignore.
* Linux: improve tryRead macro safetyChristian Göttsche2021-10-011-3/+3
| | | | | | | | | | Add an explicit else clause so a following else branch for a prior if condition does not get mixed up. Also force a trailing semicolon and thereby silence current -Wextra-semi-stmt warnings. Improve readability of the hwloc_bitmap_foreach_begin loop macro.
* Merge branch 'o_path' of https://github.com/cgzones/htop into cgzones-o_pathNathan Scott2021-09-271-0/+4
|\
| * Linux: define O_PATH if not definedChristian Göttsche2021-09-241-0/+4
| | | | | | | | | | | | | | Defining O_PATH if not defined by <fcntl.h> does not really add any maintenance cost and might improve some portability. Related: #804
* | Linux: always compute procExeDeleted if already setChristian Göttsche2021-09-241-2/+2
|/ | | | | | | | A process, whose executable has been replaced and thus marked by htop, can be re-executed with the replaced executable, with the same PID, in two ways: the Linux feature checkpoint/restore or re-execution of PID 1. The actual check is just a string comparison, like the dropped condition, leading to (almost) no computation overhead.
* Update license headers to explicitly say GPLv2+Daniel Lange2021-09-221-1/+1
|
* Linux: recalculate LRS valueChristian Göttsche2021-09-121-1/+1
| | | | | The LRS value is only zero in the first cycle; drop the check to recalculate while running.
* Linux: zero CPU data after allocationChristian Göttsche2021-09-111-7/+4
| | | | | | | | | | | | | | | | | | | | Zero all the CPU data, like totalPeriod, after its memory allocation via realloc(3). Conditional jump or move depends on uninitialised value(s) at 0x132A9B: LinuxProcessList_scanCPUTime (LinuxProcessList.c:1928) by 0x1358C3: ProcessList_goThroughEntries (LinuxProcessList.c:2079) by 0x12A79A: ProcessList_scan (ProcessList.c:627) by 0x11CA67: CommandLine_run (CommandLine.c:357) by 0x4A81E49: (below main) (libc-start.c:314) Uninitialised value was created by a heap allocation at 0x48396C5: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) by 0x12F633: xRealloc (XUtils.c:64) by 0x12F633: xReallocArray (XUtils.c:78) by 0x1325A8: LinuxProcessList_updateCPUcount (LinuxProcessList.c:207) by 0x134E0A: ProcessList_new (LinuxProcessList.c:284) by 0x11C8D0: CommandLine_run (CommandLine.c:301) by 0x4A81E49: (below main) (libc-start.c:314)
* linux: simplify recheck conditionChristian Göttsche2021-09-021-1/+1
| | | | | | `recheck` is calculated modulo 2048, so its maximum value is 2047. Drop the quite similar (up to 27 milliseconds) explicit check against 2000.
* linux: drop dead process field column DIRTYChristian Göttsche2021-09-021-2/+2
| | | | | The field for dirty pages in /proc/[pid]/statm is always 0 since Linux 2.6 (see man:proc(5)).
* IWYU updateChristian Göttsche2021-08-251-2/+1
|
* Linux: do not scan frequency for inactive CPUsChristian Göttsche2021-08-221-0/+3
|
* Respect "Show custom thread names" setting updateChristian Göttsche2021-08-141-11/+8
| | | | | | | Update merged command-line when started with "Show custom thread names" disabled and enabling at runtime. Also only consider showThreadNames when working on userland threads.
* Merge branch 'dynamic-columns' of https://github.com/smalinux/htop into ↵Nathan Scott2021-08-131-2/+2
|\ | | | | | | smalinux-dynamic-columns
| * PCP: support for 'dynamic columns' added at runtimeSohaib Mohamed2021-08-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | The average CPU utilization value must never be marked 'offline'Nathan Scott2021-08-101-1/+2
| | | | | | | | Fixes https://github.com/htop-dev/htop/issues/729
* | Add columns for process autogroup identifier and nice valueNathan Scott2021-08-091-0/+31
| | | | | | | | | | | | | | | | | | | | | | | | Adds AGRP (autogroup) and ANI (autogroup nice) columns that report the information from /proc/PID/autogroup, as well as handlers for '{' and '}' to change the autogroup nice value. This is guarded by /proc/sys/kernel/sched_autogroup_enabled such that sampling and/or changing values wont be attempted unless the kernel feature is enabled. Fixes: #720
* | Fix misc typosChristian Göttsche2021-08-081-1/+1
|/ | | | [ci skip]
* Add ProcessList_isCPUonlineChristian Göttsche2021-07-181-0/+7
|
* Rework CPU countingChristian Göttsche2021-07-181-50/+120
| | | | | | | | | | | Currently htop does not support offline CPUs and hot-swapping, e.g. via echo 0 > /sys/devices/system/cpu/cpu2/online Split the current single cpuCount variable into activeCPUs and existingCPUs. Supersedes: #650 Related: #580
* Pointer indication aligned to typenameBenny Baumann2021-07-151-5/+5
|
* Code indentationBenny Baumann2021-07-151-6/+6
|
* Add a new DynamicMeter class for runtime Meter extensionNathan Scott2021-07-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Replaces WRAP_SUBTRACT with saturatingSub inline function to reduce code ↵fraggerfox2021-06-261-14/+12
| | | | duplication.
* Do not override Linux process library sizeChristian Göttsche2021-06-121-1/+3
| | | | | | The library size in statm is unused and always 0 since Linux 2.6. Fixes: 8154125d4bf26fff20241eebe17954254409a522
* Limit deleted library checkChristian Göttsche2021-06-121-3/+4
| | | | | | | | | | Reading and parsing /proc/<pid>/maps is quite expensive. Do not check for deleted libraries if the main binary has been deleted; in this case the deleted binary takes precedence. Do not check in threads. The check is void for kernel threads and user- land threads can just inherit the state from the main process structure.
* Linux: update process uid on changeChristian Göttsche2021-06-091-7/+10
| | | | Always check if the user of a process changed, e.g. by using setuid(2).
* Linux: drop O_PATH usageChristian Göttsche2021-06-091-7/+1
| | | | | | | | O_PATH is available since Linux 2.6.39, but we are using fstat(2) on the returned file descriptor in LinuxProcessList_statProcessDir(), which is only supported since Linux 3.6. Fixes #534
* Check processes for using deleted shared librariesChristian Göttsche2021-06-091-36/+66
| | | | | | | | | Shared libraries can be replaced by an upgrade, highlight processes using deleted shared libraries. Link with highlightDeletedExe setting, enabled by default. Currently only checked on Linux.
* Move CWD field handling to platform-neutral codeBenny Baumann2021-05-251-5/+5
|
* Linux: add reset to heuristicChristian Göttsche2021-05-251-0/+7
| | | | | | On hard to parse command lines tokenStart might be computed to be bigger than tokenEnd. Reset both values in such cases.
* Fix assert failure on short running threadChristian Göttsche2021-05-231-6/+6
| | | | | | | | | | | | | | The following assert failure might happen on short running threads with an empty comm value in /proc/${pid}/stat: htop: Process.c:1159: void Process_updateCmdline(Process *, const char *, int, int): Assertion `(cmdline && basenameStart < (int)strlen(cmdline)) || (!cmdline && basenameStart == 0)' failed. The specific task is: comm='' exe='(null)' cmdline='/usr/bin/ruby /usr/bin/how-can-i-help --apt' So basenameStart is 0, while strlen(cmdline) is also 0.

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