Started working on launching child process
This commit is contained in:
@@ -3,4 +3,4 @@
|
||||
set -e
|
||||
|
||||
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
@@ -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");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("Hello, world\n");
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user