From 599ac40a9090197b5b3e9a8d8dc22bdc5b004b08 Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Wed, 2 Apr 2025 16:07:52 +0200 Subject: [PATCH] orchard ssh vm: prevent busy loop in remote terminal resize goroutine (#297) --- internal/command/ssh/vm.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/command/ssh/vm.go b/internal/command/ssh/vm.go index b669356..24ff3db 100644 --- a/internal/command/ssh/vm.go +++ b/internal/command/ssh/vm.go @@ -132,6 +132,13 @@ func runSSHVM(cmd *cobra.Command, args []string) error { // Periodically adjust remote terminal size go func() { for { + select { + case <-time.After(time.Second * time.Duration(wait)): + // Proceed with adjusting the remote terminal size + case <-cmd.Context().Done(): + return + } + newWidth, newHeight, err := term.GetSize(stdoutFD) if err != nil { return @@ -147,8 +154,6 @@ func runSSHVM(cmd *cobra.Command, args []string) error { height = newHeight width = newWidth - - time.Sleep(time.Second) } }()