cis-lclient06:~/class/nov22>more exec2.c #include #include int main(void) { int pid, i; for (i = 0; i < 5; i++) { pid = fork(); if (pid == 0) { printf("I am the child with pid %d saying goodby\n", getpid()); return; printf("The child will never get here\n"); } printf("I am the parent (pid %d) waiting for my child (pid = %d) to die\n", getpid(), pid); wait(); printf("I am the parent (pid %d) and my child (pid = %d) has died\n", getpid(), pid); } } cis-lclient06:~/class/nov22>gcc exec2.c cis-lclient06:~/class/nov22>./a.out I am the parent (pid 15712) waiting for my child (pid = 15713) to die I am the child with pid 15713 saying goodby I am the parent (pid 15712) and my child (pid = 15713) has died I am the parent (pid 15712) waiting for my child (pid = 15714) to die I am the child with pid 15714 saying goodby I am the parent (pid 15712) and my child (pid = 15714) has died I am the parent (pid 15712) waiting for my child (pid = 15715) to die I am the child with pid 15715 saying goodby I am the parent (pid 15712) and my child (pid = 15715) has died I am the parent (pid 15712) waiting for my child (pid = 15716) to die I am the child with pid 15716 saying goodby I am the parent (pid 15712) and my child (pid = 15716) has died I am the parent (pid 15712) waiting for my child (pid = 15717) to die I am the child with pid 15717 saying goodby I am the parent (pid 15712) and my child (pid = 15717) has died cis-lclient06:~/class/nov22>