signal_unix.go 678 B

12345678910111213141516171819202122232425
  1. //go:build !windows && !plan9 && !js
  2. package sys
  3. import (
  4. "os"
  5. "os/signal"
  6. "syscall"
  7. )
  8. func notifySignals() chan os.Signal {
  9. // This catches every signal regardless of whether it is ignored.
  10. sigCh := make(chan os.Signal, sigsChanBufferSize)
  11. signal.Notify(sigCh)
  12. // Calling signal.Notify will reset the signal ignore status, so we need to
  13. // call signal.Ignore every time we call signal.Notify.
  14. //
  15. // TODO: Remove this if, and when, job control is implemented. This
  16. // handles the case of running an external command from an interactive
  17. // prompt.
  18. //
  19. // See https://b.elv.sh/988.
  20. signal.Ignore(syscall.SIGTTIN, syscall.SIGTTOU, syscall.SIGTSTP)
  21. return sigCh
  22. }