24 lines
715 B
C
24 lines
715 B
C
#include <stddef.h>
|
|
#include <stdint.h>
|
|
#include <system/system.h>
|
|
#include <sysdefs/processctl.h>
|
|
#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("%-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) {
|
|
string_memcpy(namebuf, stat.name, 30);
|
|
namebuf[31] = namebuf[32] = namebuf[33] = '.';
|
|
uprintf("%-30s %3lu %-6s\n", namebuf, stat.pid, stat.kern ? "KERNEL" : "USER");
|
|
}
|
|
}
|
|
}
|