cli/command/container: hijackedIOStreamer.setupInput: use sync.OnceFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-05-21 17:34:51 +02:00
parent 97e060e7b1
commit bf2eea31b5
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C

View File

@ -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() {
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.