15 var sighupWatchers *SighupWatcher
16 var sighupCounter int32 // For testing
18 func initSighupWatcher() {
19 sighupWatchers = newSighupWatcher()
21 c := make(chan os.Signal, 1)
22 signal.Notify(c, syscall.SIGHUP)
26 sighupWatchers.closeAll()
27 atomic.AddInt32(&sighupCounter, 1)
32 // Watchces for SIGHUP events and notifies registered AutoFiles
33 type SighupWatcher struct {
35 autoFiles map[string]*AutoFile
38 func newSighupWatcher() *SighupWatcher {
39 return &SighupWatcher{
40 autoFiles: make(map[string]*AutoFile, 10),
44 func (w *SighupWatcher) addAutoFile(af *AutoFile) {
46 w.autoFiles[af.ID] = af
50 // If AutoFile isn't registered or was already removed, does nothing.
51 func (w *SighupWatcher) removeAutoFile(af *AutoFile) {
53 delete(w.autoFiles, af.ID)
57 func (w *SighupWatcher) closeAll() {
59 for _, af := range w.autoFiles {