code: func (d *stiDocker) holdHijackedConnection(tty bool, opts *RunContainerOptions, resp dockertypes.HijackedResponse) error {
  	receiveStdout := make(chan error, 1)
  	if opts.Stdout != nil || opts.Stderr != nil {
  		go func() {
  			err := d.redirectResponseToOutputStream(tty, opts.Stdout, opts.Stderr, resp.Reader)
  			if opts.Stdout != nil {
  				opts.Stdout.Close()
  				opts.Stdout = nil
  			}
  			if opts.Stderr != nil {
  				opts.Stderr.Close()
  				opts.Stderr = nil
  			}
  			receiveStdout <- err
  		}()
  	} else {
  		receiveStdout <- nil
  	}
  
  	if opts.Stdin != nil {
  		_, err := io.Copy(resp.Conn, opts.Stdin)
  		opts.Stdin.Close()
  		opts.Stdin = nil
  		if err != nil {
  			<-receiveStdout
  			return err
  		}
  	}
  	err := resp.CloseWrite()
  	if err != nil {
  		<-receiveStdout
  		return err
  	}
  
  	// Hang around until the streaming is over - either when the server closes
  	// the connection, or someone locally closes resp.
  	return <-receiveStdout
  }
docs: // holdHijackedConnection pumps data up to the container's stdin, and runs a
  // goroutine to pump data down from the container's stdout and stderr.  it holds
  // open the HijackedResponse until all of this is done.  Caller's responsibility
  // to close resp, as well as outputStream and errorStream if appropriate.