signal.go 378 B

123456789101112131415161718192021222324
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package tasker
  4. import (
  5. "os"
  6. "syscall"
  7. )
  8. var (
  9. interrupt = false
  10. )
  11. func SignalNotify(signal os.Signal) {
  12. switch signal {
  13. case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT, syscall.SIGKILL:
  14. interrupt = true
  15. }
  16. }
  17. func Interrupted() bool {
  18. return interrupt
  19. }