From bf2eea31b52be71246eb0f1bd4b5d479640d224c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 21 May 2025 17:34:51 +0200 Subject: [PATCH] cli/command/container: hijackedIOStreamer.setupInput: use sync.OnceFunc Signed-off-by: Sebastiaan van Stijn --- cli/command/container/hijack.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cli/command/container/hijack.go b/cli/command/container/hijack.go index cd91e69514..4d5ad26786 100644 --- a/cli/command/container/hijack.go +++ b/cli/command/container/hijack.go @@ -84,12 +84,9 @@ func (h *hijackedIOStreamer) setupInput() (restore func(), err error) { // Use sync.Once so we may call restore multiple times but ensure we // only restore the terminal once. - var restoreOnce sync.Once - restore = func() { - restoreOnce.Do(func() { - _ = restoreTerminal(h.streams, h.inputStream) - }) - } + restore = sync.OnceFunc(func() { + _ = restoreTerminal(h.streams, h.inputStream) + }) // Wrap the input to detect detach escape sequence. // Use default escape keys if an invalid sequence is given.