2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-18 16:42:00 +00:00
restic/internal/ui/signals/signals.go

25 lines
473 B
Go
Raw Normal View History

package signals
import (
"os"
"sync"
)
// GetProgressChannel returns a channel with which a single listener
// receives each incoming signal.
func GetProgressChannel() <-chan os.Signal {
signals.Once.Do(func() {
signals.ch = make(chan os.Signal, 1)
setupSignals()
})
return signals.ch
}
// XXX The fact that signals is a single global variable means that only one
// listener receives each incoming signal.
var signals struct {
ch chan os.Signal
sync.Once
}