Disable the +/- keybinds to adjust the update frequency and mark them inactive when the tree view in the process box is selected, as it uses both keybinds with priority.
Closes: https://github.com/aristocratos/btop/issues/1685
---------
Co-authored-by: ebignumber <ebignumber@proton.me>
Skip the synthetic swap disk entry when collecting filesystem stats on macOS. The swap row is not a real mountpoint, so calling statvfs() on it fails and leaves the async disk-stat future in an error path.
Also release IOKit properties only when IORegistryEntryCreateCFProperties() succeeds and returns a valid object, avoiding an unsafe CFRelease() after failed property creation.
Auto-collapse processes with N or more direct children when entering
tree mode. Root-level processes (depth 0 and 1) are never collapsed.
Useful for multi-process apps like Chromium, Firefox, or Electron apps
that spawn dozens of subprocesses and clutter the tree view.
Default is 0 (disabled). Example: proc_tree_auto_collapse = 4
Avoid running the full terminal resize path from the signal handler so resize notifications cannot reenter term_resize() while it already holds its guard.
Change atomic_waiting_lock::wait_for() so its timeout is measured with
an uptime clock that pauses during system suspend, while still using the
condition variable for wakeups.
Previously, std::condition_variable::wait_for() owned the timeout. If
the system suspended while the main thread was waiting for the runner
to finish, the condition-variable timeout clock could include the
suspend duration (this definitely happens on macOS). On resume, the
wait could immediately time out even though the runner had only had
milliseconds of awake time to make progress.
The new uptime_micros() helper uses the best available clock on each
platform:
- macOS: CLOCK_UPTIME_RAW (pauses during Sleep/Deep Idle)
- FreeBSD: CLOCK_UPTIME (explicitly excludes suspend time)
- Linux/OpenBSD/NetBSD: CLOCK_MONOTONIC (excludes suspend on Linux;
best available on other platforms)
This preserves the condition-variable locking model, but makes the
stall timeout count *awake* time rather than *wall clock* or *suspend*
time.
Co-authored-by: ItsMeSamey <sameychain5041@gmail.com>
Replace synchronous IOKit HID sensor reads with std::async futures
and remove all pthread_cancel() calls from the runner stall-recovery
path. This addresses the macOS/NetBSD deadlocks reported in #1349.
The root cause of the deadlocks is that pthread_cancel() does not
reliably invoke C++ destructors on macOS (libc++) or NetBSD
(libstdc++), leaving mutexes and semaphore internals wedged when the
runner thread is cancelled mid-collection.
Sensor collection via futures:
Wrap the IOKit HID thermal sensor reads (getSensors) and SMC
temperature reads in a std::async future, following the same pattern
already used for statvfs in the Linux disk collector. Each collection
cycle checks if the previous cycle's future is ready (non-blocking),
grabs the result if so, and launches a new async. Temperature
readings are delayed by at most one collection cycle (~2s), which is
imperceptible to users.
This moves the dominant cost (~130ms mean, ~700ms worst case from
77 Mach IPC roundtrips to IOKit HID sensors) off the runner's
critical path, reducing the runner cycle from ~180ms to ~50ms.
Remove pthread_cancel from stall recovery:
Replace the 5-second timeout + pthread_cancel + thread recreation
logic with a 10-second warning + 30-second clean exit. If the runner
is still stalled after 30 seconds (which should be nearly impossible
with sensor reads off the critical path), btop exits cleanly rather
than risking undefined behavior from pthread_cancel.
This follows the maintainer's recommendation: remove pthread_cancel
for BSD-derived platforms and exit with an error if the thread
stalls, with an extended timeout to allow recovery from transient
OS-level delays (sleep/wake transitions, IOKit contention).
All three timeout sites are updated:
- Runner::run(): 10s warning, 30s exit (was 5s + pthread_cancel)
- Runner::stop(): 30s exit (was 5s)
- Runner thread loop: 30s (was 5s)
- clean_quit(): remove pthread_cancel fallback from thread join
Fixes#1349