code: func (t *TermHandlers) HandlePTYReq(ch ssh.Channel, req *ssh.Request, ctx *ServerContext) error {
  	// parse and extract the requested window size of the pty
  	ptyRequest, err := parsePTYReq(req)
  	if err != nil {
  		return trace.Wrap(err)
  	}
  
  	termModes, err := ptyRequest.TerminalModes()
  	if err != nil {
  		return trace.Wrap(err)
  	}
  
  	params, err := rsession.NewTerminalParamsFromUint32(ptyRequest.W, ptyRequest.H)
  	if err != nil {
  		return trace.Wrap(err)
  	}
  	ctx.Debugf("Requested terminal %q of size %v", ptyRequest.Env, *params)
  
  	// get an existing terminal or create a new one
  	term := ctx.GetTerm()
  	if term == nil {
  		// a regular or forwarding terminal will be allocated
  		term, err = NewTerminal(ctx)
  		if err != nil {
  			return trace.Wrap(err)
  		}
  		ctx.SetTerm(term)
  	}
  	term.SetWinSize(*params)
  	term.SetTermType(ptyRequest.Env)
  	term.SetTerminalModes(termModes)
  
  	// update the session
  	if err := t.SessionRegistry.NotifyWinChange(*params, ctx); err != nil {
  		ctx.Errorf("Unable to update session: %v", err)
  	}
  
  	return nil
  }
docs: // HandlePTYReq handles requests of type "pty-req" which allocate a TTY for
  // "exec" or "shell" requests. The "pty-req" includes the size of the TTY as
  // well as the terminal type requested.