PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/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 Lø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
23--  The Process_Control package enables us to stop the server with the
24--  SIGINT, SIGPWR and SIGTERM signals.
25--  It is also this package that is responsible for creating the PID file,
26--  which by default is always placed in the same directory as the executable.
27--  Change the PID constant if you want/need it placed elsewhere.
28
29package Yolk.Process_Control is
30
31   pragma Unreserve_All_Interrupts;
32   --  Make sure that GNAT does not handle SIGINT interrupts automatically.
33   --  Check your compiler for reserved signals.
34
35   Cannot_Create_PID_File : exception;
36   --  Is raised if the PID file cannot be created, eg. the server lacks
37   --  permissions to write to the current directory.
38   Cannot_Delete_PID_File : exception;
39   --  Is raised if the PID file cannot be deleted, eg. the server lacks
40   --  permissions to write to the current directory or to the PID file itself.
41   PID_File_Exists        : exception;
42   --  Is raised when the PID file already exists, ie. the server is already
43   --  running, or it was shutdown incorrectly.
44
45   procedure Stop;
46   --  Shutdown the server.
47
48   procedure Wait;
49   --  Wait until either Stop or Controller.Handle_Kill is called. This
50   --  procedure is basically what keeps the application running. It's a
51   --  replacement for a loop in the main program file.
52   --  Wait completes when either Stop is called or the application receives
53   --  one of the SIGINT, SIGPWR or SIGTERM signals. After this, wait can be
54   --  called again.
55   --  Calling Wait multiple times in a row does nothing. Calls proceeding the
56   --  first call are ignored.
57
58end Yolk.Process_Control;