github.com/brycereitano/goa@v0.0.0-20170315073847-8ffa6c85e265/goagen/utils/signal.go (about)

     1  package utils
     2  
     3  import (
     4  	"os"
     5  	"os/signal"
     6  )
     7  
     8  // Catch signals and invoke then callback
     9  func Catch(signals []os.Signal, then func()) {
    10  	c := make(chan os.Signal)
    11  	if signals == nil {
    12  		signals = defaultSignals
    13  	}
    14  	signal.Notify(c, signals...)
    15  	<-c
    16  	if then != nil {
    17  		then()
    18  	}
    19  }