diff --git a/user/pctl/ls.c b/user/pctl/ls.c index b604578..07a305f 100644 --- a/user/pctl/ls.c +++ b/user/pctl/ls.c @@ -31,7 +31,7 @@ void pctl_ls(void) { char *namebuf = umalloc(34); char *membuf = umalloc(20); - uprintf("%-30s %s %-15s %-8s\n", "NAME", "PID", "MEMORY", "STATE"); + uprintf("%-30s %s %-15s %-8s %-25s\n", "NAME", "PID", "MEMORY", "STATE", "UPTIME"); for (size_t i = 0; i < (size_t)procslen; i++) { ProcStat stat; ZERO(&stat); @@ -58,7 +58,24 @@ void pctl_ls(void) { stat.pid, human_size(stat.usemem, membuf, 20) ); - uprintf("%-8s", states[stat.state]); + uprintf("%-8s ", states[stat.state]); + + Time time1; + time(&time1); + timeunix_t now = time_tounix(&time1); + timeunix_t procspawn = time_tounix(&stat.time); + timeunix_t diff = now - procspawn; + + char uptimebuf[100]; + + uint32_t hrs = diff / 3600; + uint32_t mins = (diff % 3600) / 60; + uint32_t secs = diff % 60; + + usprintf(uptimebuf, "%us %umin %uh", secs, mins, hrs); + + uprintf("%-25s ", uptimebuf); + uprintf("\n"); } }