diff --git a/tests/hellofork/Makefile b/tests/hellofork/Makefile new file mode 100644 index 0000000..2b0b6dd --- /dev/null +++ b/tests/hellofork/Makefile @@ -0,0 +1,12 @@ +# This is the default target, which will be built when +# you invoke make +.PHONY: all +all: hellofork + +hellofork: hellofork.c + g++ -g -o hellofork hellofork.c + +.PHONY: clean +clean: + rm -f hellofork hellofork.o + diff --git a/tests/hellofork/hellofork.c b/tests/hellofork/hellofork.c new file mode 100644 index 0000000..49e2d53 --- /dev/null +++ b/tests/hellofork/hellofork.c @@ -0,0 +1,20 @@ +#include +#include +#include + +void func(int pid, int ret) +{ + printf("My PID is %d, fork() returned %d\n", pid, ret); + + if (ret) + printf("We are in the parent process\n"); + else + printf("We are in the child process\n"); +} + +int main() +{ + int r = fork(); + func(getpid(), r); + return 0; +}