Skip to content

Commit ae922ec

Browse files
authored
Merge pull request #6092 from thaJeztah/hijack_oncefunc
cli/command/container: hijackedIOStreamer.setupInput: use sync.OnceFunc
2 parents 881c68f + bf2eea3 commit ae922ec

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

cli/command/container/hijack.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ func (h *hijackedIOStreamer) setupInput() (restore func(), err error) {
8484

8585
// Use sync.Once so we may call restore multiple times but ensure we
8686
// only restore the terminal once.
87-
var restoreOnce sync.Once
88-
restore = func() {
89-
restoreOnce.Do(func() {
90-
_ = restoreTerminal(h.streams, h.inputStream)
91-
})
92-
}
87+
restore = sync.OnceFunc(func() {
88+
_ = restoreTerminal(h.streams, h.inputStream)
89+
})
9390

9491
// Wrap the input to detect detach escape sequence.
9592
// Use default escape keys if an invalid sequence is given.

0 commit comments

Comments
 (0)