code: func (r *controller) Wait(pctx context.Context) error {
  	if err := r.checkClosed(); err != nil {
  		return err
  	}
  
  	ctx, cancel := context.WithCancel(pctx)
  	defer cancel()
  
  	healthErr := make(chan error, 1)
  	go func() {
  		ectx, cancel := context.WithCancel(ctx) // cancel event context on first event
  		defer cancel()
  		if err := r.checkHealth(ectx); err == ErrContainerUnhealthy {
  			healthErr <- ErrContainerUnhealthy
  			if err := r.Shutdown(ectx); err != nil {
  				log.G(ectx).WithError(err).Debug("shutdown failed on unhealthy")
  			}
  		}
  	}()
  
  	waitC, err := r.adapter.wait(ctx)
  	if err != nil {
  		return err
  	}
  
  	if status := <-waitC; status.ExitCode() != 0 {
  		exitErr := &exitError{
  			code: status.ExitCode(),
  		}
  
  		// Set the cause if it is knowable.
  		select {
  		case e := <-healthErr:
  			exitErr.cause = e
  		default:
  			if status.Err() != nil {
  				exitErr.cause = status.Err()
  			}
  		}
  
  		return exitErr
  	}
  
  	return nil
  }
docs: // Wait on the container to exit.