char* loader_extra = nullptr;
int detection_method = 0;
int timeout_val = 0;
- uint64_t cpu_total_time = 0;
- uint64_t cpu_idle_time = 0;
+ unsigned long long cpu_total_time = 0;
+ unsigned long long cpu_idle_time = 0;
int threshold = 0;
int threshold_max = 0;
int threshold_min = 0;
static gboolean __handle_queuing_slots(gpointer data) {
candidate_process_context_t* cpc;
- uint64_t total = 0;
- uint64_t idle = 0;
+ unsigned long long total = 0;
+ unsigned long long idle = 0;
if (__sequencer.idle_checker > 0)
return G_SOURCE_CONTINUE;
}
sent += send_ret;
- _D("send(%d: ret: %d) : %d / %d", fd, send_ret, sent, size);
+ _D("send(%d: ret: %zd) : %zd / %zd", fd, send_ret, sent, size);
}
return 0;
}
static gboolean __handle_idle_checker(gpointer data) {
- uint64_t total = 0;
- uint64_t idle = 0;
+ unsigned long long total = 0;
+ unsigned long long idle = 0;
int per;
candidate_process_context_t* cpc;
#include <unistd.h>
+#include <cstdint>
+#include <filesystem>
#include <fstream>
#include <iomanip>
#include <iostream>
return;
}
- std::ifstream file("/proc/" + std::to_string(pid) + "/smaps");
- std::string line;
- uint64_t total_pss = 0;
+ std::filesystem::path smaps_path = "/proc/" + std::to_string(pid) + "/smaps";
+ if (!std::filesystem::exists(smaps_path)) {
+ _E("%s does not exist", smaps_path.c_str());
+ return;
+ }
+
+ std::ifstream file(smaps_path);
+ if (!file) {
+ _E("Failed to open %s", smaps_path.c_str());
+ return;
+ }
+ uint64_t total_pss = 0;
+ std::string line;
while (std::getline(file, line)) {
- uint64_t pss = 0;
- if (std::sscanf(line.c_str(), "Pss: %llu kB", &pss) == 1)
- total_pss += pss;
+ std::stringstream stream(line);
+ std::string pss_str;
+ if (stream >> pss_str && pss_str == "Pss:") {
+ uint64_t pss = 0;
+ if (stream >> pss) {
+ total_pss += pss;
+ }
+ }
}
*mem_pss = total_pss;