v8.run/go/exp@v0.0.26-0.20230226010534-afcdbd3f782d/signal2/signal2.go (about) 1 package signal2 2 3 import ( 4 "os" 5 "os/signal" 6 "syscall" 7 ) 8 9 // WaitForInterrupt waits for an os.Interrupt (Ctrl+C) or SIGTERM (kill) and then return 10 func WaitForInterrupt() { 11 var ch chan os.Signal = make(chan os.Signal, 1) 12 signal.Notify(ch, os.Interrupt, syscall.SIGTERM) 13 <-ch 14 signal.Stop(ch) 15 } 16 17 // WFI waits for an os.Interrupt (Ctrl+C) or SIGTERM (kill) and then return 18 func WFI() { WaitForInterrupt() }