Replace wait with communicate to avoid potential deadlock

Wait can deadlock when using stdout=PIPE and/or stderr=PIPE and the child
process generates enough output to a pipe such that it blocks waiting for
the OS pipe buffer to accept more data. Use communicate() to avoid that.

Change-Id: I452de95834a18a970ae78ab6c43d794151ce3300
closes-bug: 1372680
3 files changed