Auto merge of #5030 - alexcrichton:better-poll, r=matklad
Auto merge of #5030 - alexcrichton:better-poll, r=matklad

Don't spin on empty fds in `read2` on Unix

This commit fixes what I think is some pathological behavior in Cargo where if
one stdio stream is closed before another then Cargo can accidentally spin in a
tight loop and not block appropriately. Previously, for example, if stderr
closed before stdout then Cargo would spin in a `poll` loop continuously getting
notified that stderr is closed.

The behavior is now changed so after a file descriptor is done we stop passing
it to `poll` and instead only pass the one remaining readable file descriptor.

nipunn1313/cargo,tsurai/cargo,rustyhorde/cargo,eminence/cargo,rust-lang/cargo,tsurai/cargo,rust-lang/cargo,rust-lang/cargo,eminence/cargo,tshepang/cargo,vojtechkral/cargo,rustyhorde/cargo,nipunn1313/cargo,vojtechkral/cargo,rustyhorde/cargo,tshepang/cargo,nipunn1313/cargo,rustyhorde/cargo,tsurai/cargo,tsurai/cargo,nipunn1313/cargo,tsurai/cargo,vojtechkral/cargo,tshepang/cargo,eminence/cargo,tshepang/cargo,eminence/cargo,rust-lang/cargo,vojtechkral/cargo