summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/.gitignore1
-rw-r--r--Userland/Makefile9
-rw-r--r--Userland/ps.cpp25
3 files changed, 33 insertions, 2 deletions
diff --git a/Userland/.gitignore b/Userland/.gitignore
index 89dadc36dd..27529b9b9b 100644
--- a/Userland/.gitignore
+++ b/Userland/.gitignore
@@ -1,3 +1,4 @@
id
sh
+ps
*.o
diff --git a/Userland/Makefile b/Userland/Makefile
index 0266a2edd0..ec3fddd381 100644
--- a/Userland/Makefile
+++ b/Userland/Makefile
@@ -1,10 +1,12 @@
OBJS = \
id.o \
- sh.o
+ sh.o \
+ ps.o
APPS = \
id \
- sh
+ sh \
+ ps
ARCH_FLAGS =
STANDARD_FLAGS = -std=c++17 -nostdinc++ -nostdlib
@@ -30,6 +32,9 @@ id: id.o
sh: sh.o
$(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
+ps: ps.o
+ $(LD) -o $@ $(LDFLAGS) $< ../LibC/LibC.a
+
.cpp.o:
@echo "CXX $<"; $(CXX) $(CXXFLAGS) -o $@ -c $<
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;
+}