diff options
author | Jos Dehaes <jos.dehaes@gmail.com> | 2021-10-06 14:10:23 +0200 |
---|---|---|
committer | Jos Dehaes <jos.dehaes@gmail.com> | 2021-10-06 14:10:23 +0200 |
commit | 70b47d2ca8a7e0927cf9613e8fe776d2405f60ee (patch) | |
tree | 905480a5c9519981a28fc64ce0ce82f298213f7a | |
parent | ca9cb48054c5850cbb3c23d368e04644a1885de0 (diff) |
reduce diff with main branch
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/btop.cpp | 1 | ||||
-rw-r--r-- | src/osx/btop_collect.cpp | 28 |
3 files changed, 29 insertions, 2 deletions
@@ -81,7 +81,7 @@ OBJEXT := o #? Flags, Libraries and Includes override REQFLAGS := -std=c++20 WARNFLAGS := -Wall -Wextra -pedantic -OPTFLAGS := -O2 -ftree-loop-vectorize -flto=$(THREADS) +OPTFLAGS ?= -O2 -ftree-loop-vectorize -flto=$(THREADS) LDCXXFLAGS := -pthread -D_FORTIFY_SOURCE=2 -D_GLIBCXX_ASSERTIONS -fexceptions $(ADDFLAGS) override CXXFLAGS += $(REQFLAGS) $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS) override LDFLAGS += $(LDCXXFLAGS) $(OPTFLAGS) $(WARNFLAGS) diff --git a/src/btop.cpp b/src/btop.cpp index c7428fd..42c8c29 100644 --- a/src/btop.cpp +++ b/src/btop.cpp @@ -304,6 +304,7 @@ namespace Runner { string empty_bg; bool pause_output = false; sigset_t mask; + pthread_t runner_id; pthread_mutex_t mtx; const unordered_flat_map<string, uint_fast8_t> box_bits = { diff --git a/src/osx/btop_collect.cpp b/src/osx/btop_collect.cpp index 749aa9c..cd6abb7 100644 --- a/src/osx/btop_collect.cpp +++ b/src/osx/btop_collect.cpp @@ -339,7 +339,6 @@ namespace Cpu { if (one_ps_descriptor) { CFDictionaryRef one_ps = IOPSGetPowerSourceDescription(ps_info, CFArrayGetValueAtIndex(one_ps_descriptor, 0)); has_battery = true; - auto state = CFDictionaryGetValue(one_ps, CFSTR(kIOPSPowerSourceStateKey)); CFNumberRef remaining = (CFNumberRef)CFDictionaryGetValue(one_ps, CFSTR(kIOPSTimeToEmptyKey)); int32_t estimatedMinutesRemaining; if (remaining) { @@ -905,6 +904,33 @@ namespace Proc { //* Get detailed info for selected process void _collect_details(const size_t pid, const uint64_t uptime, vector<proc_info> &procs) { + if (pid != detailed.last_pid) { + detailed = {}; + detailed.last_pid = pid; + detailed.skip_smaps = not Config::getB("proc_info_smaps"); + } + + //? Copy proc_info for process from proc vector + auto p_info = rng::find(procs, pid, &proc_info::pid); + detailed.entry = *p_info; + + //? Update cpu percent deque for process cpu graph + if (not Config::getB("proc_per_core")) detailed.entry.cpu_p *= Shared::coreCount; + detailed.cpu_percent.push_back(clamp((long long)round(detailed.entry.cpu_p), 0ll, 100ll)); + while (cmp_greater(detailed.cpu_percent.size(), width)) detailed.cpu_percent.pop_front(); + + //? Process runtime + detailed.elapsed = sec_to_dhms(uptime - (detailed.entry.cpu_s / Shared::clkTck)); + if (detailed.elapsed.size() > 8) detailed.elapsed.resize(detailed.elapsed.size() - 3); + + //? Get parent process name + if (detailed.parent.empty()) { + auto p_entry = rng::find(procs, detailed.entry.ppid, &proc_info::pid); + if (p_entry != procs.end()) detailed.parent = p_entry->name; + } + + //? Expand process status from single char to explanative string + detailed.status = (proc_states.contains(detailed.entry.state)) ? proc_states.at(detailed.entry.state) : "Unknown"; } //* Collects and sorts process information from /proc |