mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
Start adding a basic /proc filesystem and a "ps" utility.
This commit is contained in:
parent
98f76f0153
commit
ed2422d7af
Notes:
sideshowbarker
2024-07-19 18:44:50 +09:00
Author: https://github.com/awesomekling
Commit: ed2422d7af
13 changed files with 139 additions and 23 deletions
25
Userland/ps.cpp
Normal file
25
Userland/ps.cpp
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue