Started working on launching child process

This commit is contained in:
2026-05-17 21:30:29 +03:00
parent 1149e25616
commit 92675aee82
3 changed files with 38 additions and 2 deletions
+1 -1
View File
@@ -3,4 +3,4 @@
set -e set -e
mkdir -p build/ mkdir -p build/
gcc -std=gnu23 -I include/ src/*.c -o build/main gcc -std=gnu23 -I include/ src/*.c -o build/gandalf
+31 -1
View File
@@ -1,3 +1,33 @@
int main() { #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// #include <sys/
// _start:
// mov sp 0x120
// call main
int run_child(char *exe) {
printf("Starting %s\n", exe);
}
int main(int argc, char **argv) {
if (argc != 2) {
printf("Usage: gandalf <executable>\n");
return 1;
}
pid_t child = fork();
if (child == -1) {
printf("Failed to fork\n");
return 1;
} else if (child == 0) {
printf("Child process\n");
run_child(argv[1]);
} else {
printf("Parent process\n");
} }
}
+6
View File
@@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("Hello, world\n");
return 0;
}