summaryrefslogtreecommitdiff
path: root/user
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-28 17:28:02 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-28 17:28:02 -0400
commitd28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72 (patch)
treece096652da2f8f9889bb377b80f6aafc9bf05788 /user
parentclone pgdir (diff)
downloadcomus-d28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72.tar.gz
comus-d28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72.tar.bz2
comus-d28c5ba100cbc8a4ea6e4f4da16f5c8319a02a72.zip
fork syscall
Diffstat (limited to 'user')
-rw-r--r--user/fork.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/user/fork.c b/user/fork.c
new file mode 100644
index 0000000..d534fcf
--- /dev/null
+++ b/user/fork.c
@@ -0,0 +1,20 @@
+#include <unistd.h>
+#include <stdio.h>
+
+int main(void)
+{
+ printf("im going to print some a's and b's. get ready\n");
+
+ int pid = fork();
+ if (pid < 0) {
+ fprintf(stderr, "fork failed!\n");
+ return 1;
+ }
+
+ for (int i = 0; i < 10; i++) {
+ putchar(pid == 0 ? 'a' : 'b');
+ putchar('\n');
+ }
+
+ return 0;
+}