Skip to content

Commit

Permalink
adds return context in RunPortForward()
Browse files Browse the repository at this point in the history
Kubernetes-commit: 9e1546284302c66fda0bae12fc301ee8acf39933
  • Loading branch information
seans3 authored and k8s-publishing-bot committed Mar 2, 2024
1 parent 858d3a5 commit 1ac3b75
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/cmd/portforward/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1ac3b75

Please sign in to comment.