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

Commit 5587413

Browse files
committed
Fix STARTTIME column on FreeBSD.
1 parent 402e46b commit 5587413

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

freebsd/FreeBSDProcessList.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ in the source distribution for its full text.
1818
#include <fcntl.h>
1919
#include <limits.h>
2020
#include <string.h>
21+
#include <time.h>
2122

2223
/*{
2324
@@ -429,10 +430,14 @@ void ProcessList_goThroughEntries(ProcessList* this) {
429430
int count = 0;
430431
struct kinfo_proc* kprocs = kvm_getprocs(fpl->kd, KERN_PROC_PROC, 0, &count);
431432

433+
struct timeval tv;
434+
gettimeofday(&tv, NULL);
435+
432436
for (int i = 0; i < count; i++) {
433437
struct kinfo_proc* kproc = &kprocs[i];
434438
bool preExisting = false;
435439
bool isIdleProcess = false;
440+
struct tm date;
436441
Process* proc = ProcessList_getProcess(this, kproc->ki_pid, &preExisting, (Process_New) FreeBSDProcess_new);
437442
FreeBSDProcess* fp = (FreeBSDProcess*) proc;
438443

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

0 commit comments

Comments
 (0)