Start adding a basic /proc filesystem and a "ps" utility.

This commit is contained in:
Andreas Kling 2018-10-23 11:57:38 +02:00
commit ed2422d7af
Notes: sideshowbarker 2024-07-19 18:44:50 +09:00
13 changed files with 139 additions and 23 deletions

25
Userland/ps.cpp Normal file
View file

@ -0,0 +1,25 @@
#include <LibC/stdio.h>
#include <LibC/unistd.h>
int main(int c, char** v)
{
int fd = open("/proc/summary");
if (fd == -1) {
printf("failed to open /proc/summary :(\n");
return 1;
}
for (;;) {
char buf[16];
ssize_t nread = read(fd, buf, sizeof(buf));
if (nread == 0)
break;
if (nread < 0) {
printf("failed to read :(\n");
return 2;
}
for (ssize_t i = 0; i < nread; ++i) {
putchar(buf[i]);
}
}
return 0;
}