in reply to how to determine pipe process terminated or alive
Regarding your first example, when you close a pipe, a wait is done also, so your explicit wait is not necessary.