/src/yolk-process_control.ads

http://github.com/ThomasLocke/yolk · Ada · 58 lines · 8 code · 7 blank · 43 comment · 0 complexity · 6b89ad6a5616c26859e5e257dfa980ca MD5 · raw file

  1. -------------------------------------------------------------------------------
  2. -- --
  3. -- Copyright (C) 2010-, Thomas ¸cke --
  4. -- --
  5. -- This library is free software; you can redistribute it and/or modify --
  6. -- it under terms of the GNU General Public License as published by the --
  7. -- Free Software Foundation; either version 3, or (at your option) any --
  8. -- later version. This library is distributed in the hope that it will be --
  9. -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of --
  10. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
  11. -- --
  12. -- As a special exception under Section 7 of GPL version 3, you are --
  13. -- granted additional permissions described in the GCC Runtime Library --
  14. -- Exception, version 3.1, as published by the Free Software Foundation. --
  15. -- --
  16. -- You should have received a copy of the GNU General Public License and --
  17. -- a copy of the GCC Runtime Library Exception along with this program; --
  18. -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
  19. -- <http://www.gnu.org/licenses/>. --
  20. -- --
  21. -------------------------------------------------------------------------------
  22. -- The Process_Control package enables us to stop the server with the
  23. -- SIGINT, SIGPWR and SIGTERM signals.
  24. -- It is also this package that is responsible for creating the PID file,
  25. -- which by default is always placed in the same directory as the executable.
  26. -- Change the PID constant if you want/need it placed elsewhere.
  27. package Yolk.Process_Control is
  28. pragma Unreserve_All_Interrupts;
  29. -- Make sure that GNAT does not handle SIGINT interrupts automatically.
  30. -- Check your compiler for reserved signals.
  31. Cannot_Create_PID_File : exception;
  32. -- Is raised if the PID file cannot be created, eg. the server lacks
  33. -- permissions to write to the current directory.
  34. Cannot_Delete_PID_File : exception;
  35. -- Is raised if the PID file cannot be deleted, eg. the server lacks
  36. -- permissions to write to the current directory or to the PID file itself.
  37. PID_File_Exists : exception;
  38. -- Is raised when the PID file already exists, ie. the server is already
  39. -- running, or it was shutdown incorrectly.
  40. procedure Stop;
  41. -- Shutdown the server.
  42. procedure Wait;
  43. -- Wait until either Stop or Controller.Handle_Kill is called. This
  44. -- procedure is basically what keeps the application running. It's a
  45. -- replacement for a loop in the main program file.
  46. -- Wait completes when either Stop is called or the application receives
  47. -- one of the SIGINT, SIGPWR or SIGTERM signals. After this, wait can be
  48. -- called again.
  49. -- Calling Wait multiple times in a row does nothing. Calls proceeding the
  50. -- first call are ignored.
  51. end Yolk.Process_Control;