mirror of
https://github.com/octoleo/restic.git
synced 2024-11-23 21:27:34 +00:00
25 lines
473 B
Go
25 lines
473 B
Go
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
|
|
}
|