unix_shutdown_actor_unix.go 550 B

123456789101112131415161718192021222324252627282930
  1. //go:build unix
  2. package rpcore
  3. import (
  4. "context"
  5. "syscall"
  6. )
  7. type UnixSignalShutdownActor struct {
  8. }
  9. func (u UnixSignalShutdownActor) Shutdown(info *ShutdownInfo, ctx context.Context) bool {
  10. if info == nil {
  11. return false
  12. }
  13. if info.Cmd == nil {
  14. return false
  15. }
  16. if info.Cmd.Process == nil {
  17. return false
  18. }
  19. err = info.Cmd.Process.Signal(syscall.SIGINT)
  20. if err != nil {
  21. info.LogEmitFunc(fmt.Sprintf("error in sending SIGINT to process (CPID=%16X, PID=%d): %v", info.CPID, info.PID, err))
  22. return false
  23. } else {
  24. return true
  25. }
  26. }