adds return context in RunPortForward()

This commit is contained in:
Sean Sullivan 2024-03-01 21:10:32 -08:00
parent 8b447d8c97
commit 9e15462843

View File

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