adds return context in RunPortForward()

Kubernetes-commit: 9e1546284302c66fda0bae12fc301ee8acf39933
This commit is contained in:
Sean Sullivan 2024-03-01 21:10:32 -08:00 committed by Kubernetes Publisher
parent 858d3a5b72
commit 1ac3b7558a
1 changed files with 4 additions and 1 deletions

View File

@ -420,10 +420,13 @@ func (o PortForwardOptions) RunPortForwardContext(ctx context.Context) error {
signal.Notify(signals, os.Interrupt)
defer signal.Stop(signals)
returnCtx, returnCtxCancel := context.WithCancel(ctx)
defer returnCtxCancel()
go func() {
select {
case <-signals:
case <-ctx.Done():
case <-returnCtx.Done():
}
if o.StopChannel != nil {
close(o.StopChannel)