Make run_command process communication smarter

The run_command module function will now poll stdout/stderr for
data rather than using the builtin command communicate(), which can
hang under certain circumstances.

Fixes #7452
Fixes #7748
Fixes #8163