Avoid busy waiting and make sure to capture the full output