/** * Outputs the Collatz sequence in the child process. * * exercise 3.21 * */ #include #include #include #define is_even(N) ( ((N % 2) == 0) ? 1 : 0) int main(int argc, char *argv[]) { pid_t pid; int n; /* just shows how to run the program */ if (argc == 1) { fprintf(stderr,"Usage: ./a.out \n"); return -1; } n = atoi(argv[1]); /* run an instance of a fork */ /* add a check to see if the OS was unable to create the child /* /* if pid ==0 (we're in the child) , do what ? 1. print the original number 2. While we haven't reached 1 if even divide by to and resent it to this if odd, mult by 3 and add 1 3. print the numbers as they are made if not child (parent) what should we do? */ return 0; }