collect_output_and_wait t
closes stdin t
and then begins collecting the output
produced on t
's stdout
and stderr
, continuing to collect output until t
terminates and the pipes for stdout
and stderr
are closed. Usually when t
terminates, the pipes are closed; however, t
could fork other processes which
survive after t
terminates and in turn keep the pipes open -- wait
will not become
determined until both pipes are closed in all descendant processes.