summaryrefslogtreecommitdiff
path: root/Userland/ps.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-10-23 11:57:38 +0200
committerAndreas Kling <awesomekling@gmail.com>2018-10-23 12:04:03 +0200
commited2422d7afbf0368c5dc828c7280a4d1c0473039 (patch)
tree206815b1f66e5675aa59a7112326fab9abf9a4f4 /Userland/ps.cpp
parent98f76f0153004b348c49b45cdb4b653a9be6a3a1 (diff)
downloadserenity-ed2422d7afbf0368c5dc828c7280a4d1c0473039.zip
Start adding a basic /proc filesystem and a "ps" utility.
Diffstat (limited to 'Userland/ps.cpp')
-rw-r--r--Userland/ps.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Userland/ps.cpp b/Userland/ps.cpp
new file mode 100644
index 0000000000..5b620d96e4
--- /dev/null
+++ b/Userland/ps.cpp
@@ -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;
+}