wait output thread to reach eof before restart