Commit Graph

41 Commits

Author SHA1 Message Date
Christian Göttsche
04cf590967 FreeBSD: drop minflt and implement majflt 2021-01-30 14:21:26 +01:00
Christian Göttsche
399add39ca FreeBSD: simplify kernel thread logic 2021-01-30 14:21:26 +01:00
Christian Göttsche
fa499fc155 FreeBSD: misc 2021-01-30 14:21:26 +01:00
Daniel Lange
4531b31d92 Sort out the mess around column sorting that had accumulated over time 2021-01-21 14:27:23 +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
Christian Göttsche
90ea3ac3c9 Object: return int on comparison
Comparisons do, due to the new introduced shaceship-comparisons,
only return -1, 0, 1 or the result of strcmp().
2021-01-02 00:00:17 +01:00
Christian Göttsche
9f68c8d341 Merge Process_pidColumns into Process_fields and rework auto-fit for PID-like columns 2020-12-19 21:13:32 +01:00
Christian Göttsche
89473cc9ae Rework enum ProcessField
Use only one enum instead of a global and a platform specific one.
Drop Platform_numberOfFields global variable.
Set known size of Process_fields array
2020-12-19 21:13:32 +01:00
Benny Baumann
77db240b48 Split boilerplate and platform-independent field comparison
This acheives two things:
- Allows for simple tie-breaking if values compare equal (needed to make sorting the tree-view stable)
- Allows for platform-dependent overriding of the sort-order for specific fields

Also fixes a small oversight on DragonFlyBSD when default-sorting.
2020-12-19 16:02:34 +01:00
Hisham Muhammad
3d1703f16f Invert Process_compare resolution so that superclass matches run first
* This removes duplicated code that adjusts the sort direction from every
  OS-specific folder.
* Most fields in a regular htop screen are OS-independent, so trying
  Process_compare first and only falling back to the OS-specific
  compareByKey function if it's an OS-specific field makes sense.
* This will allow us to override the sortKey in a global way without having
  to edit each OS-specific file.
2020-12-19 16:02:34 +01:00
Christian Göttsche
157086e750 Split RichString_(append|appendn|write) into wide and ascii
RichString_writeFrom takes a top spot during performance analysis due to the
calls to mbstowcs() and iswprint().

Most of the time we know in advance that we are only going to print regular
ASCII characters.
2020-12-08 20:58:40 +01:00
Christian Göttsche
fa002c0ba9 Rename virtual memory column from M_SIZE to M_VIRT
Closes: #325
2020-11-21 19:39:45 +01:00
Christian Goettsche
f5c3349bdb IWYU update (FreeBSD) 2020-11-19 23:51:50 +01:00
Christian Göttsche
15eab2012d Add process column for normalized CPU usage
Shows the process CPU usage divided by the number of CPU cores
2020-11-16 18:14:06 +01:00
Christian Göttsche
397b5c4bd0 Introduce spaceship comparison for Processes
If currently two unsigned values are compared via `a - b`, in the case b
is actually bigger than a, the result will not be an negative number (as
-1 is expected) but a huge positive number as the subtraction is an
unsigned subtraction.

Avoid over-/underflow affected operations; use comparisons.
Modern compilers will generate sane code, like:
    xor     eax, eax
    cmp     rdi, rsi
    seta    al
    sbb     eax, 0
    ret
2020-11-15 18:25:21 +01:00
Benny Baumann
45869513bf Embracing branches 2020-11-02 22:15:01 +01:00
Benny Baumann
61e14d4bb2 Spacing around operators 2020-11-02 22:15:01 +01:00
Christian Göttsche
049046c700 FreeBSD: update Process 2020-10-29 22:21:42 +01:00
Christian Goettsche
88eec2dc00 FreeBSD: rework tty process column 2020-10-29 22:21:42 +01:00
Christian Göttsche
4eb443926f Hold only a const version of Settings in Process 2020-10-26 19:30:38 +01:00
Christian Göttsche
7109172431 Mark process parameter of Process_writeField consistently const 2020-10-26 19:30:38 +01:00
Christian Göttsche
7af06659e2 Mark remaining classes const 2020-10-13 14:56:01 +02:00
Christian Göttsche
41eea8a355 Mark process argument of Process_isThread const 2020-10-09 10:18:40 +02:00
Christian Göttsche
db472075a4 Enable -Wcast-qual compiler warning 2020-10-06 11:20:07 +02:00
Daniel Lange
079c2abf8e Update License consistently to GPLv2 as per COPYING file 2020-10-05 10:13:12 +02:00
Zev Weiss
a1a027b9bd Axe automated header generation.
Reasoning:
 - implementation was unsound -- broke down when I added a fairly
   basic macro definition expanding to a struct initializer in a *.c
   file.

 - made it way too easy (e.g. via otherwise totally innocuous git
   commands) to end up with timestamps such that it always ran
   MakeHeader.py but never used its output, leading to overbuild noise
   when running what should be a null 'make'.

 - but mostly: it's just an awkward way of dealing with C code.
2020-09-03 11:58:58 -05:00
Nathan Scott
e833bf915f Merge branch 'hishamhm-pull-904' 2020-08-20 14:01:33 +10:00
Robert Crowston
fabe75685a Truncate overwide jail names on BSD. 2019-04-17 10:07:13 +01:00
Daniel Lange
c34be41e1c Widen ST_UID (UID) column to 5 chars to allow UIDs > 9999 without breaking alignment
Issue Github #841, Debian bug #910492
2018-10-07 11:16:12 +02:00
Hisham Muhammad
09e241fb12 Security review: check results of snprintf.
Calls marked with xSnprintf shouldn't fail.
Abort program cleanly if any of them does.
2017-07-27 16:07:50 -03:00
Kamyar Rasta
3f6d1262c0 Issue #502 fix SID colunm header width 2017-02-05 00:10:29 +01:00
Kamyar Rasta
84bc00a275 Issue #502 update Session ID column 2017-02-01 00:03:55 +01:00
Hisham
8af4d9f453 Interpret TTY_NR column on Linux,
translate dev_t to major:minor on other platforms.
Closes #316.
2016-10-01 03:09:04 -03:00
Hung-Yi Chen
cc4267cc5c Suppress compiler warnings. 2016-02-13 02:09:50 +08:00
Hisham
b54d2dde40 Check for failure in allocations. 2016-02-02 15:53:02 +01:00
Martin "eto" Misuth
8c00fa4582 Added preliminary attempt at jails support on FreeBSD - JID and JAIL (name) columns, somewhat more correct kernel "thread" detection.
Seems FreeBSD kernel can spawn both kernel processes (what is what htop currently sees) and kernel threads.
For now let's consider kernel processes kernel "threads".
2015-09-30 22:04:26 +02:00
Christian Hesse
e8970b6f32 fix calloc() calls
* size_t nmemb (number of elements) first, then size_t size
* do not assume char is size 1 but use sizeof()
* allocate for char, not pointer to char (found by Michael McConville,
  fixes #261)
2015-09-07 07:52:39 +02:00
Hisham Muhammad
9428010121 Make column width calculation dynamic.
Closes #228.
2015-08-20 00:32:47 -03:00
Hisham Muhammad
b291fba02b Fixes to use platform-specific compare routines. 2015-04-09 15:40:46 -03:00
Hisham Muhammad
272e2d9b34 Major advances in FreeBSD port. 2015-03-16 23:02:03 -03:00
Hisham Muhammad
adbfe3c3f1 Get FreeBSD tree to compile again with latest changes. 2015-03-16 03:14:20 -03:00