spawn_glib_23.0.0_440f8b8a/source/spawn/spawn-processes-monitor-osx_initialize.adb

 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
--
--  Copyright (C) 2018-2020, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0
--

--
--  This is an OSX implementation. For some reason, we are unable to catch
--  SIGCHLD signal until it's enabled for the environment task.
--

with Ada.Interrupts.Names;
with Interfaces.C;

pragma Warnings (Off);
with System.OS_Interface;
pragma Warnings (Off);

separate (Spawn.Processes.Monitor)
procedure Initialize is
   Ignore : Interfaces.C.int;
   Value  : aliased System.OS_Interface.struct_sigaction :=
     (sa_flags    => 0,
      others      => <>);
begin
   --  Reset sigaction to call a null procedure
   Ignore := System.OS_Interface.sigemptyset
     (Value.sa_mask'Unrestricted_Access);
   --  Set dummy procedure as the handler
   Value.sa_handler := Dummy'Address;

   --  Assign the custom handler to SIGCHLD signal
   Ignore := System.OS_Interface.sigaction
     (System.OS_Interface.Signal (Ada.Interrupts.Names.SIGCHLD),
      Value'Unchecked_Access,
      null);
end Initialize;