Add helper function for waitpid().