1------------------------------------------------------------------------------ 2-- -- 3-- FLORIST (FSU Implementation of POSIX.5) COMPONENTS -- 4-- -- 5-- P O S I X . S I G N A L S -- 6-- -- 7-- S p e c -- 8-- -- 9-- -- 10-- This file is a component of FLORIST, an implementation of the POSIX -- 11-- Ada bindings for use with the GNAT Ada compiler and the FSU Gnu Ada -- 12-- Runtime Library (GNARL). -- 13-- -- 14-- This package specification contains some text extracted from IEEE STD -- 15-- 1003.5: 1990, Information Technology -- POSIX Ada Language Interfaces -- 16-- Part 1: Binding for System Application Program Interface, as amended -- 17-- by IEEE STD 1003.5b: 1996, Amendment 1: Realtime Extensions, copyright -- 18-- 1996 by the Institute of Electrical and Electronics Engineers, Inc. -- 19-- -- 20-- The package specifications in the IEEE standards cited above represent -- 21-- only a portion of the documents and are not to be interpreteted -- 22-- outside the context of the documents. The standards must be used in -- 23-- conjunction with the package specifications in order to claim -- 24-- conformance. The IEEE takes no responsibility for and will assume no -- 25-- liability for damages resulting from the reader's misinterpretation of -- 26-- said information resulting from its out-of-context nature. To order -- 27-- copies of the IEEE standards, please contact the IEEE Service Center -- 28-- at 445 Hoes Lane, PO Box 1331, Piscataway, NJ 08855-1331; via phone at -- 29-- 1-800-678-IEEE, 908-981-1393; or via fax at 908-981-9667. -- 30-- -- 31-- These package specifications are distributed in the hope that they -- 32-- will be useful, but WITHOUT ANY WARRANTY; without even the implied -- 33-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 34-- -- 35------------------------------------------------------------------------------ 36 37with Ada.Task_Identification, 38 Ada.Finalization, 39 POSIX, 40 POSIX.C, 41 POSIX.Process_Identification, 42 System, 43 System.Interrupt_Management, 44 System.Storage_Elements; 45 46-- To ensure that this file does not get compiled when thread support is 47-- disabled 48pragma Warnings (Off); 49with POSIX.Implementation.OK_Signals; 50pragma Warnings (On); 51 52package POSIX.Signals is 53 54 -- Signal Type 55 56 type Signal is 57 new System.Interrupt_Management.Interrupt_ID'Base 58 range 0 .. POSIX.C.NSIGS; 59 for Signal'Size use POSIX.C.int'Size; 60 61 function Image (Sig : Signal) return String; 62 function Value (Str : String) return Signal; 63 64 -- Standard Signals (required) 65 66 Signal_Null, 67 SIGNULL : constant Signal := 0; 68 Signal_Abort, 69 SIGABRT : constant Signal := POSIX.C.SIGABRT; 70 Signal_Alarm, 71 SIGALRM : constant Signal := POSIX.C.SIGALRM; 72 Signal_Bus_Error, 73 SIGBUS : constant Signal := POSIX.C.SIGBUS; 74 Signal_Floating_Point_Error, 75 SIGFPE : constant Signal := POSIX.C.SIGFPE; 76 Signal_Hangup, 77 SIGHUP : constant Signal := POSIX.C.SIGHUP; 78 Signal_Illegal_Instruction, 79 SIGILL : constant Signal := POSIX.C.SIGILL; 80 Signal_Interrupt, 81 SIGINT : constant Signal := POSIX.C.SIGINT; 82 Signal_Kill, 83 SIGKILL : constant Signal := POSIX.C.SIGKILL; 84 Signal_Pipe_Write, 85 SIGPIPE : constant Signal := POSIX.C.SIGPIPE; 86 Signal_Quit, 87 SIGQUIT : constant Signal := POSIX.C.SIGQUIT; 88 Signal_Segmentation_Violation, 89 SIGSEGV : constant Signal := POSIX.C.SIGSEGV; 90 Signal_Terminate, 91 SIGTERM : constant Signal := POSIX.C.SIGTERM; 92 Signal_User_1, 93 SIGUSR1 : constant Signal := POSIX.C.SIGUSR1; 94 Signal_User_2, 95 SIGUSR2 : constant Signal := POSIX.C.SIGUSR2; 96 97 -- Standard Signals (job control) 98 99 Signal_Child, 100 SIGCHLD : constant Signal := POSIX.C.SIGCHLD; 101 Signal_Continue, 102 SIGCONT : constant Signal := POSIX.C.SIGCONT; 103 Signal_Stop, 104 SIGSTOP : constant Signal := POSIX.C.SIGSTOP; 105 Signal_Terminal_Stop, 106 SIGTSTP : constant Signal := POSIX.C.SIGTSTP; 107 Signal_Terminal_Input, 108 SIGTTIN : constant Signal := POSIX.C.SIGTTIN; 109 Signal_Terminal_Output, 110 SIGTTOU : constant Signal := POSIX.C.SIGTTOU; 111 112 -- Signals from P1003.5c 113 114 Signal_IO, 115 SIGIO : constant Signal := POSIX.C.SIGIO; 116 Signal_Out_Of_Band_Data, 117 SIGURG : constant Signal := POSIX.C.SIGURG; 118 119 subtype Realtime_Signal is Signal range 120 POSIX.C.SIGRTMIN .. POSIX.C.SIGRTMAX; 121 122 -- Signal sets 123 124 type Signal_Set is private; 125 126 procedure Add_Signal 127 (Set : in out Signal_Set; 128 Sig : Signal); 129 procedure Add_All_Signals (Set : in out Signal_Set); 130 procedure Delete_Signal 131 (Set : in out Signal_Set; 132 Sig : Signal); 133 procedure Delete_All_Signals (Set : in out Signal_Set); 134 function Is_Member 135 (Set : Signal_Set; 136 Sig : Signal) 137 return Boolean; 138 139 -- Blocking and Unblocking Signals 140 141 procedure Set_Blocked_Signals 142 (New_Mask : Signal_Set; 143 Old_Mask : out Signal_Set); 144 procedure Block_Signals 145 (Mask_to_Add : Signal_Set; 146 Old_Mask : out Signal_Set); 147 procedure Unblock_Signals 148 (Mask_to_Subtract : Signal_Set; 149 Old_Mask : out Signal_Set); 150 function Blocked_Signals return Signal_Set; 151 152 -- Ignoring Signals 153 154 procedure Ignore_Signal (Sig : Signal); 155 procedure Unignore_Signal (Sig : Signal); 156 function Is_Ignored (Sig : Signal) return Boolean; 157 procedure Install_Empty_Handler (Sig : Signal); 158 159 -- Controlling Delivery of Signal_Child Signal 160 161 procedure Set_Stopped_Child_Signal (Enable : Boolean := True); 162 function Stopped_Child_Signal_Enabled return Boolean; 163 164 -- Examining Pending Signals 165 166 function Pending_Signals return Signal_Set; 167 type Signal_Event is private; 168 type Signal_Data is private; 169 170 type Notification is range Integer'First .. Integer'Last; 171 No_Notification : constant Notification := POSIX.C.SIGEV_NONE; 172 Signal_Notification : constant Notification := POSIX.C.SIGEV_SIGNAL; 173 174 function Get_Signal (Event : Signal_Event) return Signal; 175 procedure Set_Signal 176 (Event : in out Signal_Event; 177 Sig : Signal); 178 function Get_Notification (Event : Signal_Event) return Notification; 179 procedure Set_Notification 180 (Event : in out Signal_Event; 181 Notify : Notification); 182 function Get_Data (Event : Signal_Event) return Signal_Data; 183 procedure Set_Data 184 (Event : in out Signal_Event; 185 Data : Signal_Data); 186 187 type Signal_Source is range Integer'First .. Integer'Last; 188 From_Send_Signal : constant Signal_Source := POSIX.C.SI_USER; 189 From_Queue_Signal : constant Signal_Source := POSIX.C.SI_QUEUE; 190 From_Timer : constant Signal_Source := POSIX.C.SI_TIMER; 191 From_Async_IO : constant Signal_Source := POSIX.C.SI_ASYNCIO; 192 From_Message_Queue : constant Signal_Source := POSIX.C.SI_MESGQ; 193 194 type Signal_Info is private; 195 function Get_Signal (Info : Signal_Info) return Signal; 196 procedure Set_Signal 197 (Info : in out Signal_Info; 198 Sig : Signal); 199 function Get_Source (Info : Signal_Info) return Signal_Source; 200 procedure Set_Source 201 (Info : in out Signal_Info; 202 Source : Signal_Source); 203 function Has_Data (Source : Signal_Source) return Boolean; 204 function Get_Data (Info : Signal_Info) return Signal_Data; 205 procedure Set_Data 206 (Info : in out Signal_Info; 207 Data : Signal_Data); 208 209 procedure Enable_Queueing (Sig : Signal); 210 procedure Disable_Queueing (Sig : Signal); 211 212 function Await_Signal (Set : Signal_Set) return Signal; 213 function Await_Signal_Or_Timeout 214 (Set : Signal_Set; 215 Timeout : POSIX.Timespec) 216 return Signal; 217 function Await_Signal (Set : Signal_Set) return Signal_Info; 218 function Await_Signal_Or_Timeout 219 (Set : Signal_Set; 220 Timeout : POSIX.Timespec) 221 return Signal_Info; 222 223 Signal_Abort_Ref : constant System.Address 224 := System.Storage_Elements.To_Address 225 (System.Storage_Elements.Integer_Address (SIGABRT)); 226 Signal_Hangup_Ref : constant System.Address 227 := System.Storage_Elements.To_Address 228 (System.Storage_Elements.Integer_Address (SIGHUP)); 229 Signal_Interrupt_Ref : constant System.Address 230 := System.Storage_Elements.To_Address 231 (System.Storage_Elements.Integer_Address (SIGINT)); 232 Signal_Pipe_Write_Ref : constant System.Address 233 := System.Storage_Elements.To_Address 234 (System.Storage_Elements.Integer_Address (SIGPIPE)); 235 Signal_Quit_Ref : constant System.Address 236 := System.Storage_Elements.To_Address 237 (System.Storage_Elements.Integer_Address (SIGQUIT)); 238 Signal_Terminate_Ref : constant System.Address 239 := System.Storage_Elements.To_Address 240 (System.Storage_Elements.Integer_Address (SIGTERM)); 241 Signal_User_1_Ref : constant System.Address 242 := System.Storage_Elements.To_Address 243 (System.Storage_Elements.Integer_Address (SIGUSR1)); 244 Signal_User_2_Ref : constant System.Address 245 := System.Storage_Elements.To_Address 246 (System.Storage_Elements.Integer_Address (SIGUSR2)); 247 Signal_Child_Ref : constant System.Address 248 := System.Storage_Elements.To_Address 249 (System.Storage_Elements.Integer_Address (SIGCHLD)); 250 Signal_Continue_Ref : constant System.Address 251 := System.Storage_Elements.To_Address 252 (System.Storage_Elements.Integer_Address (SIGCONT)); 253 Signal_Terminal_Stop_Ref : constant System.Address 254 := System.Storage_Elements.To_Address 255 (System.Storage_Elements.Integer_Address (SIGTSTP)); 256 Signal_Terminal_Input_Ref : constant System.Address 257 := System.Storage_Elements.To_Address 258 (System.Storage_Elements.Integer_Address (SIGTTIN)); 259 Signal_Terminal_Output_Ref : constant System.Address 260 := System.Storage_Elements.To_Address 261 (System.Storage_Elements.Integer_Address (SIGTTOU)); 262 263 function Signal_Reference (Sig : Signal) return System.Address; 264 265 procedure Send_Signal 266 (Process : POSIX.Process_Identification.Process_ID; 267 Sig : Signal); 268 procedure Send_Signal 269 (Group : POSIX.Process_Identification.Process_Group_ID; 270 Sig : Signal); 271 procedure Send_Signal (Sig : Signal); 272 273 procedure Queue_Signal 274 (Process : POSIX.Process_Identification.Process_ID; 275 Sig : Signal; 276 Data : Signal_Data); 277 278 procedure Interrupt_Task 279 (T : Ada.Task_Identification.Task_Id); 280 281private 282 283 type Signal_Set is new Ada.Finalization.Controlled with record 284 C : aliased POSIX.C.sigset_t; 285 end record; 286 287 procedure Initialize (Set : in out Signal_Set); 288 procedure Finalize (Set : in out Signal_Set); 289 290 -- We formerly used an explicit array, rather than the C type 291 -- sigset_t, because: 292 -- 1. C provides no operation to enumerate the 293 -- members of a sigset_t, other than calling sigismember() for 294 -- every value in the range of valid Signals. 295 -- 2. We would have to use a controlled type to do the initialization, 296 -- since making a sigset_t object empty requires calling sigemptyset. 297 -- We should have put the array inside a record, to get 298 -- default initialization, but did not -- a mistake that needed 299 -- correcting in any case. 300 -- 3. We thought objects of type sigset_t might involve implicitly 301 -- allocated dynamic storage, which could lead to storage leakage, 302 -- and would not support private-type (assignment) semantics. 303 -- Unfortunately, using this different representation meant quite a 304 -- bit of extra computation, to translate between the two forms, and 305 -- that ends up with iteration over the range of valid Signals anyway. 306 -- The current solution does assume that the sigset_t representation 307 -- supports meaningful equality testing. 308 309 type Signal_Info is new POSIX.C.siginfo_t; 310 type Signal_Event is new POSIX.C.struct_sigevent; 311 type Signal_Data is record 312 Data : System.Storage_Elements.Storage_Array 313 (1 .. POSIX.C.sigval_byte_size); 314 end record; 315 for Signal_Data'Alignment use POSIX.C.sigval_alignment; 316 317end POSIX.Signals; 318