Close stdout/stderr pipes when the main process of an action terminates so that we can properly finish reading from it even if it passed them on to a subprocess that did *not* terminate.
Close stdout/stderr pipes when the main process of an action terminates so that we can properly finish reading from it even if it passed them on to a subprocess that did *not* terminate.

The alternative would be to rely on job control.

Fixes #1708. Hopefully.

Tested by running test_cpp 10 times and observing that it doesn't hang.

--
MOS_MIGRATED_REVID=131945117

katre/bazel,iamthearm/bazel,perezd/bazel,snnn/bazel,perezd/bazel,dslomov/bazel,twitter-forks/bazel,dslomov/bazel,hermione521/bazel,werkt/bazel,juhalindfors/bazel-patches,safarmer/bazel,kchodorow/bazel,juhalindfors/bazel-patches,twitter-forks/bazel,ulfjack/bazel,akira-baruah/bazel,Asana/bazel,spxtr/bazel,kchodorow/bazel,ButterflyNetwork/bazel,ulfjack/bazel,snnn/bazel,dslomov/bazel-windows,zhexuany/bazel,mikelikespie/bazel,twitter-forks/bazel,twitter-forks/bazel,variac/bazel,meteorcloudy/bazel,davidzchen/bazel,LuminateWireless/bazel,hermione521/bazel,ButterflyNetwork/bazel,mbrukman/bazel,meteorcloudy/bazel,snnn/bazel,damienmg/bazel,werkt/bazel,dslomov/bazel,dropbox/bazel,damienmg/bazel,perezd/bazel,dslomov/bazel,kchodorow/bazel,iamthearm/bazel,safarmer/bazel,dslomov/bazel-windows,perezd/bazel,katre/bazel,Asana/bazel,Asana/bazel,kchodorow/bazel-1,safarmer/bazel,spxtr/bazel,cushon/bazel,zhexuany/bazel,dropbox/bazel,mrdomino/bazel,aehlig/bazel,hermione521/bazel,juhalindfors/bazel-patches,safarmer/bazel,mrdomino/bazel,bazelbuild/bazel,mrdomino/bazel,meteorcloudy/bazel,dropbox/bazel,cushon/bazel,dslomov/bazel,safarmer/bazel,dslomov/bazel-windows,mrdomino/bazel,iamthearm/bazel,mbrukman/bazel,aehlig/bazel,cushon/bazel,spxtr/bazel,werkt/bazel,ButterflyNetwork/bazel,dropbox/bazel,cushon/bazel,dslomov/bazel-windows,akira-baruah/bazel,mbrukman/bazel,mikelikespie/bazel,kchodorow/bazel-1,damienmg/bazel,mrdomino/bazel,spxtr/bazel,katre/bazel,meteorcloudy/bazel,katre/bazel,mikelikespie/bazel,mbrukman/bazel,snnn/bazel,bazelbuild/bazel,juhalindfors/bazel-patches,Asana/bazel,dslomov/bazel,mikelikespie/bazel,damienmg/bazel,kchodorow/bazel,dropbox/bazel,zhexuany/bazel,aehlig/bazel,ButterflyNetwork/bazel,cushon/bazel,dslomov/bazel-windows,ulfjack/bazel,mikelikespie/bazel,kchodorow/bazel-1,LuminateWireless/bazel,perezd/bazel,ulfjack/bazel,akira-baruah/bazel,snnn/bazel,snnn/bazel,kchodorow/bazel-1,akira-baruah/bazel,safarmer/bazel,damienmg/bazel,mrdomino/bazel,twitter-forks/bazel,Asana/bazel,davidzchen/bazel,dslomov/bazel-windows,juhalindfors/bazel-patches,LuminateWireless/bazel,werkt/bazel,variac/bazel,kchodorow/bazel,damienmg/bazel,bazelbuild/bazel,dropbox/bazel,akira-baruah/bazel,akira-baruah/bazel,iamthearm/bazel,hermione521/bazel,aehlig/bazel,zhexuany/bazel,perezd/bazel,aehlig/bazel,katre/bazel,juhalindfors/bazel-patches,cushon/bazel,damienmg/bazel,kchodorow/bazel-1,davidzchen/bazel,mikelikespie/bazel,zhexuany/bazel,kchodorow/bazel,Asana/bazel,aehlig/bazel,spxtr/bazel,variac/bazel,spxtr/bazel,hermione521/bazel,variac/bazel,juhalindfors/bazel-patches,LuminateWireless/bazel,katre/bazel,bazelbuild/bazel,mbrukman/bazel,twitter-forks/bazel,variac/bazel,davidzchen/bazel,hermione521/bazel,ulfjack/bazel,kchodorow/bazel-1,ButterflyNetwork/bazel,werkt/bazel,bazelbuild/bazel,meteorcloudy/bazel,werkt/bazel,perezd/bazel,mbrukman/bazel,twitter-forks/bazel,meteorcloudy/bazel,dslomov/bazel,zhexuany/bazel,kchodorow/bazel,snnn/bazel,bazelbuild/bazel,iamthearm/bazel,LuminateWireless/bazel,davidzchen/bazel,meteorcloudy/bazel,spxtr/bazel,ulfjack/bazel,davidzchen/bazel,aehlig/bazel,davidzchen/bazel,variac/bazel,variac/bazel,ulfjack/bazel,iamthearm/bazel,ButterflyNetwork/bazel,LuminateWireless/bazel,Asana/bazel