Commit Graph

123 Commits

Author SHA1 Message Date
Nathan Scott 579995c7c2 Merge branch 'hishamhm-pull-842' 2020-08-18 17:35:56 +10:00
Hisham Muhammad 90518bfc84 Return of snprintf is not the number of written bytes 2019-02-10 14:16:46 +01:00
Alan Barr f49f545813 Fix printf() unsigned placeholders
Unsigned numbers should be using "%u".

Raised by cppcheck
2019-02-10 14:16:46 +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 0dbedf95a8 Collapse current subtree pressing Backspace 2018-04-05 19:38:13 -03:00
Kang-Che Sung (宋岡哲) c01f40eb3e Fix build failure ('major' undefined) in glibc 2.28. (#746)
glibc 2.28 no longer defines 'major' and 'minor' in <sys/types.h> and
requires us to include <sys/sysmacros.h>. (glibc 2.25 starts
deprecating the macros in <sys/types.h>.) Now do include the latter if
found on the system.

At the moment, let's also utilize AC_HEADER_MAJOR in configure script.
However as Autoconf 2.69 has not yet updated the AC_HEADER_MAJOR macro
to reflect the glibc change [1], so add a workaround code.

Fixes #663. Supersedes pull request #729.

Reference:
[1] https://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commit;h=e17a30e987d7ee695fb4294a82d987ec3dc9b974

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
2018-02-26 10:15:05 -03:00
Hisham Muhammad 8c653212c0 Replace size_t with int/void* union
I was occasionally passing negative values to size_t.
Plus, this better reflects the intent of the variant argument.

Reported by Coverity:
https://scan8.coverity.com/reports.htm#v13253/p10402/fileInstanceId=22093891&defectInstanceId=7543346&mergedDefectId=174179&fileStart=251&fileEnd=500
2018-02-18 10:38:49 -03:00
Vladimir Panteleev 87be623eac Add support for Linux TASK_IDLE
Linux commit 06eb61844d841d0032a9950ce7f8e783ee49c0d0 ("sched/debug:
Add explicit TASK_IDLE printing") exposes kthreads idling using
TASK_IDLE in procfs as "I (idle)".

Until now, when sorting the STATE ("S") column, htop used the raw
value of the state character for comparison, however that led to the
undesirable effect of TASK_IDLE ('I') tasks being sorted above tasks
that were running ('R').

Thus, explicitly recognize the idle process state, and sort it below
others.
2018-02-04 16:44:21 +01:00
Hisham Muhammad e3f65c8ec2 Make 'c' key work with threads as well. 2017-09-14 17:10:39 -03: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
Hisham Muhammad 543d65c6ab Security review: make privilege dropping-restoring optional.
This is/was necessary only on macOS, because you needed root in order
to read the process list. This was never necessary on Linux, and
it also raises security concerns, so now it needs to be enabled
explicitly at build time.
2017-07-26 15:40:55 -03:00
Hisham Muhammad e940aecfb9 Add "no perm" status when other fields fail due to lack of permission.
Thanks @Sworddragon for the heads up.
See #88.
2017-07-10 20:57:34 -03:00
Tomasz Kramkowski 2b5c1b4b13 Replace all uses of sprintf with snprintf
In all the cases where sprintf was being used within htop, snprintf
could have been used. This patch replaces all uses of sprintf with
snprintf which makes sure that if a buffer is too small to hold the
resulting string, the string is simply cut short instead of causing
a buffer overflow which leads to undefined behaviour.

`sizeof(variable)` was used in these cases, as opposed to `sizeof
variable` which is my personal preference because `sizeof(variable)`
was already used in one way or another in other parts of the code.
2016-12-29 19:42:41 +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
Ivan Kozik 07086fcf77 Fix column misalignment for priority -101 threads
BFS-patched kernels can have kernel threads with priority -101.
This change makes priority -101 display as "RT", just like priority -100.

Related: https://github.com/hishamhm/htop/issues/314
2016-09-06 09:22:38 +00:00
Hisham 7d5ef246f1 Let's keep it simple then! 2016-06-20 12:11:49 -03:00
Hisham 52f814481c While we're at it, get rid of another sprintf. 2016-06-19 18:30:20 -03:00
Hisham 7ededce9b5 Silence cast warning. 2016-05-30 12:22:07 -03:00
Hisham fa0c637c55 Silence warnings about seteuid return value.
Closes #483.
2016-05-25 21:37:07 -03:00
Hisham fa1b5d1e2e Fix a small undefined behavior detected by libubsan. 2016-05-04 15:34:22 -03:00
Hisham 797bcd0961 Catch invalid IO values due to no permissions.
Display them properly. Not fully convinced of the "no perm" message...
2016-02-20 02:23:26 -02:00
Hisham f1f805f29f Support -1 as tpgid 2016-02-10 18:48:04 -02:00
Hisham 1cfcc42a8f Reuse comm object if possible, avoid useless repetitions of free+strdup. 2016-02-02 15:56:52 +01:00
Michael Klein ab3a7c2fa8 drop privileges before changing process priority or sending signals
- replaces uid check from d18e9a4895
2015-12-07 20:10:09 +01:00
Michael Klein d18e9a4895 add some security checks when running SUID root
on Darwin, htop needs to run with root privileges to display information
about other users processes. This commit makes running htop SUID root a
bit more safe.
2015-12-02 22:56:01 +01:00
Hisham Muhammad 9428010121 Make column width calculation dynamic.
Closes #228.
2015-08-20 00:32:47 -03:00
David Hunt 5e602f18d5 Rename String to StringUtils.
Fixes building on case-insensitive filesystems where String.h gets confused with <string.h>.

From d734dacea0a10d0465dad4e95b3421511e7da112 Mon Sep 17 00:00:00 2001
From: David Hunt <dhunt@iolanthe.attlocal.net>
Date: Sat, 11 Jul 2015 20:56:31 -0500
Subject: [PATCH 1/8] Rename String to StringUtils
2015-08-19 13:45:20 -03:00
Tobias Geerinckx-Rice 293eec4265 New setting: "Show program path"
Add a setting to hide all but the last component from the programme
path, leaving only the "basename". Makes htop more usable on smaller
screens, or systems with longer than average paths. Off by default.

"Highlight program basename" will still be respected, to further
visually separate process names from their arguments.
2015-08-07 14:20:14 +02:00
sherpya a8e1c1c63f added missing defines for android 2015-05-20 04:30:11 +02:00
Hisham Muhammad d880def0e9 Merge branch 'master' into wip
Conflicts:
	Process.c
	Process.h
	htop.c
	linux/LinuxProcess.c
	linux/LinuxProcess.h
	test_spec.lua
2015-04-02 01:57:37 -03:00
Hisham Muhammad 4c24a9b462 Fixes to subclassing Process. 2015-03-31 23:23:10 -03:00
Hisham Muhammad b1b3f57976 Tempus fugit.
Conflicts:
	htop.c
	htop.h
2015-03-23 18:15:56 -03:00
Hisham Muhammad 1e0c530a46 Tempus fugit. 2015-03-21 16:52:54 -03:00
Hisham Muhammad 272e2d9b34 Major advances in FreeBSD port. 2015-03-16 23:02:03 -03:00
Hisham Muhammad be1700cf94 Isolate portable and Linux-specific process fields. 2015-03-16 01:43:04 -03:00
Hisham Muhammad e3fe3962cb Move more Linux-specific code into Linux subdir. 2015-03-15 20:29:13 -03:00
Hisham Muhammad 0a184b769f Merge fixes 2015-02-23 03:53:36 -03:00
Hisham Muhammad 9780c312f4 Fix allocation of processes. Closes #166.
Conflicts:
	Process.c
	Process.h
	ProcessList.c
	ScreenManager.c
	linux/LinuxProcessList.c
2015-02-23 01:13:40 -03:00
Hisham Muhammad 6f868b00c0 Fix allocation of processes. Closes #166. 2015-02-20 14:52:10 -02:00
Hisham Muhammad 3383d8e556 Sorry about the mega-patch.
This is a work-in-progress, code is currently broken.
(Some actions, and notably, the header, are missing.)
2015-01-21 23:27:31 -02:00
Hisham Muhammad b4f6b11092 Move "get max pid" code into platform specific area. 2014-11-27 20:10:23 -02:00
Hisham Muhammad aaaaf063a1 Builds on Linux again! 2014-11-24 19:22:50 -02:00
Hisham Muhammad eb229d9aef Changes for supporting separate platform subdirectories. 2014-11-24 18:55:03 -02:00
Valmiky Arquissandas b2e94d626d Fixed a wrong attribution. 2014-10-14 02:48:17 +01:00
Valmiky Arquissandas 64e0d9452d Added new color for 'D' state. 2014-10-14 02:30:17 +01:00
Hisham Muhammad f54a37b4a9 Update values for fields whose columns may appear later. Fixes #80. 2014-05-03 17:51:19 -03:00
Hisham Muhammad c3e66b2d81 Make VPID use PID-width format. Closes #79. 2014-05-03 17:26:11 -03:00
Hisham Muhammad 78d09f955a Compare with long, for 64-bit systems 2014-04-25 19:41:23 -03:00
Hisham Muhammad d7e5020169 Merge branch 'master' of https://github.com/hishamhm/htop 2014-04-25 19:37:41 -03:00
Hisham Muhammad ea191b53bd Fix time-based sorting 2014-04-25 19:37:07 -03:00