File: posix-process_primitives.ads

package info (click to toggle)
libflorist 2011-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,948 kB
  • sloc: ada: 11,664; ansic: 7,164; makefile: 204
file content (214 lines) | stat: -rw-r--r-- 8,387 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
------------------------------------------------------------------------------
--                                                                          --
--            FLORIST (FSU Implementation of POSIX.5) COMPONENTS            --
--                                                                          --
--              P O S I X . P R O C E S S _ P R I M I T I V E S             --
--                                                                          --
--                                  S p e c                                 --
--                                                                          --
--                                                                          --
--  This  file is a component  of FLORIST,  an implementation of the POSIX  --
--  Ada  bindings  for  use with the GNAT Ada compiler and the FSU Gnu Ada  --
--  Runtime Library (GNARL).                                                --
--                                                                          --
--  This package specification contains some text extracted from  IEEE STD  --
--  1003.5: 1990, Information Technology -- POSIX Ada Language  Interfaces  --
--  Part 1: Binding  for  System Application Program Interface, as amended  --
--  by IEEE STD 1003.5b: 1996, Amendment 1: Realtime Extensions, copyright  --
--  1996 by the Institute of Electrical and Electronics Engineers, Inc.     --
--                                                                          --
--  The package specifications in the IEEE standards cited above represent  --
--  only a  portion  of  the  documents  and  are  not to be interpreteted  --
--  outside the context  of  the documents.  The standards must be used in  --
--  conjunction  with  the  package   specifications  in  order  to  claim  --
--  conformance.   The IEEE takes no responsibility for and will assume no  --
--  liability for damages resulting from the reader's misinterpretation of  --
--  said  information resulting from its out-of-context nature.   To order  --
--  copies of the IEEE standards,  please contact the  IEEE Service Center  --
--  at 445 Hoes Lane, PO Box 1331, Piscataway, NJ 08855-1331; via phone at  --
--  1-800-678-IEEE, 908-981-1393; or via fax at 908-981-9667.               --
--                                                                          --
--  These  package  specifications are  distributed in  the hope that they  --
--  will  be useful, but  WITHOUT  ANY  WARRANTY; without even the implied  --
--  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.        --
--                                                                          --
------------------------------------------------------------------------------

with POSIX,
     POSIX.C,
     POSIX.IO,
     POSIX.Process_Environment,
     POSIX.Process_Identification,
     POSIX.Signals;
package POSIX.Process_Primitives is

   --  Process Template

   type Process_Template is limited private;

   procedure Open_Template (Template : in out Process_Template);

   procedure Close_Template (Template : in out Process_Template);

   procedure Set_Keep_Effective_IDs
     (Template : in out Process_Template);

   procedure Set_Signal_Mask
     (Template : in out Process_Template;
      Mask : POSIX.Signals.Signal_Set);

   procedure Set_Creation_Signal_Masking
     (Template : in out Process_Template;
      Masked_Signals : POSIX.Signal_Masking
                     := POSIX.RTS_Signals);

   procedure Set_File_Action_To_Close
     (Template : in out Process_Template;
      File : POSIX.IO.File_Descriptor);

   procedure Set_File_Action_To_Open
     (Template : in out Process_Template;
      File : POSIX.IO.File_Descriptor;
      Name : POSIX.Pathname;
      Mode : POSIX.IO.File_Mode := POSIX.IO.Read_Only;
      Options : POSIX.IO.Open_Option_Set := POSIX.IO.Empty_Set);

   procedure Set_File_Action_To_Duplicate
     (Template : in out Process_Template;
      File : POSIX.IO.File_Descriptor;
      From_File : POSIX.IO.File_Descriptor);

   --  Process Creation

   procedure Start_Process
     (Child : out POSIX.Process_Identification.Process_ID;
      Pathname : POSIX.Pathname;
      Template : Process_Template;
      Arg_List : POSIX.POSIX_String_List
               := POSIX.Empty_String_List);

   procedure Start_Process
     (Child : out POSIX.Process_Identification.Process_ID;
      Pathname : POSIX.Pathname;
      Template : Process_Template;
      Env_List : POSIX.Process_Environment.Environment;
      Arg_List : POSIX.POSIX_String_List
               := POSIX.Empty_String_List);

   procedure Start_Process_Search
     (Child : out POSIX.Process_Identification.Process_ID;
      Filename : POSIX.Filename;
      Template : Process_Template;
      Arg_List : POSIX.POSIX_String_List
               := POSIX.Empty_String_List);

   procedure Start_Process_Search
     (Child : out POSIX.Process_Identification.Process_ID;
      Filename : POSIX.Filename;
      Template : Process_Template;
      Env_List : POSIX.Process_Environment.Environment;
      Arg_List : POSIX.POSIX_String_List
               := POSIX.Empty_String_List);

   --  Process Exit

   type Exit_Status is range 0 .. 2**8-1;
   Normal_Exit              : constant Exit_Status := 0;
   Failed_Creation_Exit     : constant Exit_Status := 41;
   Unhandled_Exception_Exit : constant Exit_Status := 42;

   procedure Exit_Process (Status : Exit_Status := Normal_Exit);

   --  Termination Status

   type Termination_Status is private;
   type Termination_Cause  is
     (Exited, Terminated_By_Signal, Stopped_By_Signal);

   function Status_Available (Status : Termination_Status)
      return Boolean;

   function Process_ID_Of (Status : Termination_Status)
      return POSIX.Process_Identification.Process_ID;

   function Termination_Cause_Of (Status : Termination_Status)
      return Termination_Cause;

   function Exit_Status_Of (Status : Termination_Status)
      return Exit_Status;

   function Termination_Signal_Of (Status : Termination_Status)
      return POSIX.Signals.Signal;

   function Stopping_Signal_Of (Status : Termination_Status)
      return POSIX.Signals.Signal;

   --  Wait for Process Termination

   procedure Wait_For_Child_Process
     (Status : out Termination_Status;
      Child : POSIX.Process_Identification.Process_ID;
      Block : Boolean := True;
      Trace_Stopped : Boolean := True;
      Masked_Signals : POSIX.Signal_Masking
                     := POSIX.RTS_Signals);

   procedure Wait_For_Child_Process
     (Status : out Termination_Status;
      Group : POSIX.Process_Identification.Process_Group_ID;
      Block : Boolean := True;
      Trace_Stopped : Boolean := True;
      Masked_Signals : POSIX.Signal_Masking
                     := POSIX.RTS_Signals);

   procedure Wait_For_Child_Process
     (Status : out Termination_Status;
      Block : Boolean := True;
      Trace_Stopped : Boolean := True;
      Masked_Signals : POSIX.Signal_Masking
                     := POSIX.RTS_Signals);

private

   type Termination_Status is
      record
         pid : POSIX.C.pid_t := POSIX.C.pid_t (Integer'(-1));
         stat_val : aliased POSIX.C.int := 0;
      end record;

   type FD_Action_Type is (Open, Close, Duplicate);

   type FD_Set_Element
     (FD_Action : FD_Action_Type;
      File_Name_Size : Positive);
   type FD_Set_Ptr is access FD_Set_Element;
   type FD_Set_Element
     (FD_Action : FD_Action_Type;
      File_Name_Size : Positive) is
      record
         FD : POSIX.IO.File_Descriptor;
         Next : FD_Set_Ptr;
         Action : FD_Action_Type;
         case FD_Action is
            when Close =>
               null;
            when Open  =>
               File_Name : POSIX.Pathname (1 .. File_Name_Size);
               File_Mode : POSIX.IO.File_Mode;
               File_Options : POSIX.IO.Open_Option_Set;
            when Duplicate =>
               Dup_From : POSIX.IO.File_Descriptor;
         end case;
      end record;

   type Process_Template is
      record
         Is_Closed : Boolean := True;
         Keep_Effective_IDs : Boolean;
         Sig_Set : POSIX.Signals.Signal_Set;
         --  Implicitly initialized to no signal by POSIX_Signals.
         Masked_Sig : POSIX.Signal_Masking := POSIX.RTS_Signals;
         FD_Set : FD_Set_Ptr;
      end record;

end POSIX.Process_Primitives;