code: func ServeExec(w http.ResponseWriter, req *http.Request, executor Executor, podName string, uid types.UID, container string, cmd []string, streamOpts *Options, idleTimeout, streamCreationTimeout time.Duration, supportedProtocols []string) {
  	ctx, ok := createStreams(req, w, streamOpts, supportedProtocols, idleTimeout, streamCreationTimeout)
  	if !ok {
  		// error is handled by createStreams
  		return
  	}
  	defer ctx.conn.Close()
  
  	err := executor.ExecInContainer(podName, uid, container, cmd, ctx.stdinStream, ctx.stdoutStream, ctx.stderrStream, ctx.tty, ctx.resizeChan, 0)
  	if err != nil {
  		if exitErr, ok := err.(utilexec.ExitError); ok && exitErr.Exited() {
  			rc := exitErr.ExitStatus()
  			ctx.writeStatus(&apierrors.StatusError{ErrStatus: metav1.Status{
  				Status: metav1.StatusFailure,
  				Reason: remotecommandconsts.NonZeroExitCodeReason,
  				Details: &metav1.StatusDetails{
  					Causes: []metav1.StatusCause{
  						{
  							Type:    remotecommandconsts.ExitCodeCauseType,
  							Message: fmt.Sprintf("%d", rc),
  						},
  					},
  				},
  				Message: fmt.Sprintf("command terminated with non-zero exit code: %v", exitErr),
  			}})
  		} else {
  			err = fmt.Errorf("error executing command in container: %v", err)
  			runtime.HandleError(err)
  			ctx.writeStatus(apierrors.NewInternalError(err))
  		}
  	} else {
  		ctx.writeStatus(&apierrors.StatusError{ErrStatus: metav1.Status{
  			Status: metav1.StatusSuccess,
  		}})
  	}
  }
docs: // ServeExec handles requests to execute a command in a container. After
  // creating/receiving the required streams, it delegates the actual execution
  // to the executor.