#include #include #include #include long int fib(int n){ if(n > 2) return fib(n-1) + fib(n-2); return 1; } int main(){ pid_t result; result = fork(); printf("result = %d\n", result); if(result){ // We are the parent printf("Parent calculates fib(48) = %ld\n", fib(48)); printf("Starting even harder calculation! We'll wait on the child first.\n"); wait(0); printf("Parent calculates fib(49) = %ld\n", fib(49)); } else { // We are the child printf("Child calculates fib(45) = %ld\n", fib(45)); } return 0; }