Clean up process wait to use POSIX waitpid() interface.