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

Commit 87c05ac

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

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

freebsd/FreeBSDProcessList.c

Lines changed: 8 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

@@ -523,6 +528,9 @@ void ProcessList_goThroughEntries(ProcessList* this) {
523528
this->kernelThreads++;
524529
}
525530

531+
(void) localtime_r((time_t*) &proc->starttime_ctime, &date);
532+
strftime(proc->starttime_show, 7, ((proc->starttime_ctime > tv.tv_sec - 86400) ? "%R " : "%b%d "), &date);
533+
526534
this->totalTasks++;
527535
if (proc->state == 'R')
528536
this->runningTasks++;

0 commit comments

Comments
 (0)