From 92675aee82520944ae17a8c7795ea13cde5bf8c0 Mon Sep 17 00:00:00 2001 From: Shlyakhtun Prokhor Date: Sun, 17 May 2026 21:30:29 +0300 Subject: [PATCH] Started working on launching child process --- build.sh | 2 +- src/main.c | 32 +++++++++++++++++++++++++++++++- tests/main.c | 6 ++++++ 3 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 tests/main.c diff --git a/build.sh b/build.sh index 65ef6a2..80c0d85 100755 --- a/build.sh +++ b/build.sh @@ -3,4 +3,4 @@ set -e mkdir -p build/ -gcc -std=gnu23 -I include/ src/*.c -o build/main \ No newline at end of file +gcc -std=gnu23 -I include/ src/*.c -o build/gandalf \ No newline at end of file diff --git a/src/main.c b/src/main.c index cc98203..a2b7b85 100644 --- a/src/main.c +++ b/src/main.c @@ -1,3 +1,33 @@ -int main() { +#include +#include +#include +// #include \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"); + + } } \ No newline at end of file diff --git a/tests/main.c b/tests/main.c new file mode 100644 index 0000000..6380ac8 --- /dev/null +++ b/tests/main.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello, world\n"); + return 0; +} \ No newline at end of file