#include #include #include #include #include #include #include #include #include "child.h" pid_t run_child (int rc) { char *str = "I am the parent"; // TODO: Add code here to create a child process that prints // "I am the child" and exits with return code passed as the rc // parameter to this function. The parent must wait for the child // to finish before printing the child's exit status (consult the // textbook for this as needed) before printing "I am the parent". // The parent should return the child's PID from this function. int status = 0; pid_t pid = fork (); if (pid == 0) { printf ("I am the child\n"); exit (rc); } else { waitpid (pid, &status, 0); } printf ("Child exited with status %d\n", WEXITSTATUS (status)); printf ("%s\n", str); return pid; }