summaryrefslogtreecommitdiffstats
path: root/darwin/DarwinProcess.c
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-10-13 14:26:40 +0200
committercgzones <cgzones@googlemail.com>2020-10-16 19:23:40 +0200
commita63cfc8b7c172aa7e849521a479d39af737681a8 (patch)
treeccc59220f05cfa581ee09018a90ab72c6ef4aa28 /darwin/DarwinProcess.c
parent783be7711db0081a77fbcf84fbb63ab2a31ccc05 (diff)
Refactor generating starttime string into Process class
Diffstat (limited to 'darwin/DarwinProcess.c')
-rw-r--r--darwin/DarwinProcess.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/darwin/DarwinProcess.c b/darwin/DarwinProcess.c
index 8c90c2a5..48574e2f 100644
--- a/darwin/DarwinProcess.c
+++ b/darwin/DarwinProcess.c
@@ -50,14 +50,6 @@ bool Process_isThread(const Process* this) {
return false;
}
-void DarwinProcess_setStartTime(Process *proc, struct extern_proc *ep, time_t now) {
- struct tm date;
-
- proc->starttime_ctime = ep->p_starttime.tv_sec;
- (void) localtime_r(&proc->starttime_ctime, &date);
- strftime(proc->starttime_show, 7, ((proc->starttime_ctime > now - 86400) ? "%R " : "%b%d "), &date);
-}
-
char *DarwinProcess_getCmdLine(struct kinfo_proc* k, int* basenameOffset) {
/* This function is from the old Mac version of htop. Originally from ps? */
int mib[3], argmax, nargs, c = 0;
@@ -201,7 +193,7 @@ ERROR_A:
return retval;
}
-void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, time_t now, bool exists) {
+void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, bool exists) {
struct extern_proc *ep = &ps->kp_proc;
/* UNSET HERE :
@@ -231,7 +223,9 @@ void DarwinProcess_setFromKInfoProc(Process *proc, struct kinfo_proc *ps, time_t
/* e_tdev == -1 for "no device" */
proc->tty_nr = ps->kp_eproc.e_tdev & 0xff; /* TODO tty_nr is unsigned */
- DarwinProcess_setStartTime(proc, ep, now);
+ proc->starttime_ctime = ep->p_starttime.tv_sec;
+ Process_fillStarttimeBuffer(proc);
+
proc->comm = DarwinProcess_getCmdLine(ps, &(proc->basenameOffset));
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy