github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/signal.go (about) 1 package main 2 3 import ( 4 "log" 5 "os" 6 "os/signal" 7 ) 8 9 func initSignalHandlers() { 10 // Setup a listener for interrupts (SIGINT) and just black hole 11 // the signals. We do this because subcommands should setup additional 12 // listeners if they care. And if we don't do this then the subprocesses 13 // we execute such as Terraform and Vagrant never receive the ctrl-C 14 // and can't gracefully clean up. 15 signalCh := make(chan os.Signal, 2) 16 signal.Notify(signalCh, os.Interrupt) 17 go func() { 18 for { 19 <-signalCh 20 log.Printf("[DEBUG] main: interrupt received. ignoring since command should also listen") 21 } 22 }() 23 }