pctl More compact output of ls subcmd
This commit is contained in:
@ -5,15 +5,19 @@
|
||||
#include <util/util.h>
|
||||
#include <errors.h>
|
||||
#include <uprintf.h>
|
||||
#include <string/string.h>
|
||||
|
||||
void pctl_ls(void) {
|
||||
uint64_t procslen = processctl(-1, PCTL_PLS_SZ, 0, 0, 0);
|
||||
uprintf("%-80s %s %-6s\n", "NAME", "PID", "TYPE");
|
||||
uprintf("%-30s %s %-6s\n", "NAME", "PID", "TYPE");
|
||||
for (size_t i = 0; i < procslen; i++) {
|
||||
ProcStat stat = ZERO(&stat);
|
||||
char namebuf[34] = {0};
|
||||
int32_t r = processctl(-1, PCTL_PLS_STAT, i, (uint64_t)&stat, 0);
|
||||
if (r == E_OK) {
|
||||
uprintf("%-80s %3lu %-6s\n", stat.name, stat.pid, stat.kern ? "KERNEL" : "USER");
|
||||
string_memcpy(namebuf, stat.name, 30);
|
||||
namebuf[31] = namebuf[32] = namebuf[33] = '.';
|
||||
uprintf("%-30s %3lu %-6s\n", namebuf, stat.pid, stat.kern ? "KERNEL" : "USER");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user