Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
Fix STARTTIME column on FreeBSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobCrowston committed Dec 29, 2019
1 parent 402e46b commit 5587413
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions freebsd/FreeBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ in the source distribution for its full text.
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <time.h>

/*{
Expand Down Expand Up @@ -429,10 +430,14 @@ void ProcessList_goThroughEntries(ProcessList* this) {
int count = 0;
struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count);

struct timeval tv;
gettimeofday(&tv, NULL);

for (int i = 0; i < count; i++) {
struct kinfo_proc* kproc = &kprocs[i];
bool preExisting = false;
bool isIdleProcess = false;
struct tm date;
Process* proc = ProcessList_getProcess(this, kproc->ki_pid, &preExisting, (Process_New) FreeBSDProcess_new);
FreeBSDProcess* fp = (FreeBSDProcess*) proc;

Expand All @@ -457,6 +462,8 @@ void ProcessList_goThroughEntries(ProcessList* this) {
ProcessList_add((ProcessList*)this, proc);
proc->comm = FreeBSDProcessList_readProcessName(fpl->kd, kproc, &proc->basenameOffset);
fp->jname = FreeBSDProcessList_readJailName(kproc);
(void) localtime_r((time_t*) &proc->starttime_ctime, &date);
strftime(proc->starttime_show, 7, ((proc->starttime_ctime > tv.tv_sec - 86400) ? "%R " : "%b%d "), &date);
} else {
if(fp->jid != kproc->ki_jid) {
// process can enter jail anytime
Expand Down

0 comments on commit 5587413

Please sign in to comment.