Put Process.waitpid in the same loop

I think there is no need for another loop here.
Process.waitpid can safely be put after Process.kill.