signals_windows.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2019-2022 Nicola Murino
  2. //
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU Affero General Public License as published
  5. // by the Free Software Foundation, version 3.
  6. //
  7. // This program is distributed in the hope that it will be useful,
  8. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. // GNU Affero General Public License for more details.
  11. //
  12. // You should have received a copy of the GNU Affero General Public License
  13. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. package service
  15. import (
  16. "os"
  17. "os/signal"
  18. "github.com/drakkan/sftpgo/v2/internal/logger"
  19. "github.com/drakkan/sftpgo/v2/internal/plugin"
  20. )
  21. func registerSignals() {
  22. c := make(chan os.Signal, 1)
  23. signal.Notify(c, os.Interrupt)
  24. go func() {
  25. for range c {
  26. logger.Debug(logSender, "", "Received interrupt request")
  27. plugin.Handler.Cleanup()
  28. os.Exit(0)
  29. }
  30. }()
  31. }