Use waitpid to wait for children