FreeBSD: misc

This commit is contained in:
Christian Göttsche 2021-01-27 15:11:50 +01:00 committed by BenBE
parent fdaa15bd8d
commit fa499fc155
3 changed files with 9 additions and 9 deletions

View File

@ -65,9 +65,10 @@ void Process_delete(Object* cast) {
static void FreeBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) { static void FreeBSDProcess_writeField(const Process* this, RichString* str, ProcessField field) {
const FreeBSDProcess* fp = (const FreeBSDProcess*) this; const FreeBSDProcess* fp = (const FreeBSDProcess*) this;
char buffer[256]; buffer[255] = '\0'; char buffer[256];
size_t n = sizeof(buffer);
int attr = CRT_colors[DEFAULT_COLOR]; int attr = CRT_colors[DEFAULT_COLOR];
int n = sizeof(buffer) - 1;
switch (field) { switch (field) {
// add FreeBSD-specific fields here // add FreeBSD-specific fields here
case JID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, fp->jid); break; case JID: xSnprintf(buffer, n, "%*d ", Process_pidDigits, fp->jid); break;

View File

@ -471,10 +471,10 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
} }
int count = 0; int count = 0;
struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count); const struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
struct kinfo_proc* kproc = &kprocs[i]; const struct kinfo_proc* kproc = &kprocs[i];
bool preExisting = false; bool preExisting = false;
// TODO: bool isIdleProcess = false; // TODO: bool isIdleProcess = false;
Process* proc = ProcessList_getProcess(super, kproc->ki_pid, &preExisting, FreeBSDProcess_new); Process* proc = ProcessList_getProcess(super, kproc->ki_pid, &preExisting, FreeBSDProcess_new);
@ -543,7 +543,7 @@ void ProcessList_goThroughEntries(ProcessList* super, bool pauseProcessUpdate) {
proc->priority = kproc->ki_pri.pri_level - PZERO; proc->priority = kproc->ki_pri.pri_level - PZERO;
if (strcmp("intr", kproc->ki_comm) == 0 && kproc->ki_flag & P_SYSTEM) { if (String_eq("intr", kproc->ki_comm) && (kproc->ki_flag & P_SYSTEM)) {
proc->nice = 0; //@etosan: intr kernel process (not thread) has weird nice value proc->nice = 0; //@etosan: intr kernel process (not thread) has weird nice value
} else if (kproc->ki_pri.pri_class == PRI_TIMESHARE) { } else if (kproc->ki_pri.pri_class == PRI_TIMESHARE) {
proc->nice = kproc->ki_nice - NZERO; proc->nice = kproc->ki_nice - NZERO;

View File

@ -138,7 +138,7 @@ void Platform_setBindings(Htop_Action* keys) {
int Platform_getUptime() { int Platform_getUptime() {
struct timeval bootTime, currTime; struct timeval bootTime, currTime;
int mib[2] = { CTL_KERN, KERN_BOOTTIME }; const int mib[2] = { CTL_KERN, KERN_BOOTTIME };
size_t size = sizeof(bootTime); size_t size = sizeof(bootTime);
int err = sysctl(mib, 2, &bootTime, &size, NULL, 0); int err = sysctl(mib, 2, &bootTime, &size, NULL, 0);
@ -152,7 +152,7 @@ int Platform_getUptime() {
void Platform_getLoadAverage(double* one, double* five, double* fifteen) { void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
struct loadavg loadAverage; struct loadavg loadAverage;
int mib[2] = { CTL_VM, VM_LOADAVG }; const int mib[2] = { CTL_VM, VM_LOADAVG };
size_t size = sizeof(loadAverage); size_t size = sizeof(loadAverage);
int err = sysctl(mib, 2, &loadAverage, &size, NULL, 0); int err = sysctl(mib, 2, &loadAverage, &size, NULL, 0);
@ -214,7 +214,6 @@ double Platform_setCPUValues(Meter* this, int cpu) {
} }
void Platform_setMemoryValues(Meter* this) { void Platform_setMemoryValues(Meter* this) {
// TODO
const ProcessList* pl = this->pl; const ProcessList* pl = this->pl;
this->total = pl->totalMem; this->total = pl->totalMem;
@ -243,7 +242,7 @@ void Platform_setZfsCompressedArcValues(Meter* this) {
} }
char* Platform_getProcessEnv(pid_t pid) { char* Platform_getProcessEnv(pid_t pid) {
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ENV, pid }; const int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_ENV, pid };
size_t capacity = ARG_MAX; size_t capacity = ARG_MAX;
char* env = xMalloc(capacity); char* env = xMalloc(capacity);