Put Process.waitpid in the same loop