Partition-Wide Settings (GNAT User’s Guide for Native Platforms)

#### 3.11.4 Partition-Wide Settings ¶

When building a mixed-language application, you must be aware that Ada enforces some partition-wide settings that may implicitly impact the behavior of the other languages.

This is the case for certain signals that are reserved to the implementation to implement proper Ada semantics (such as the behavior of `abort` statements). It means that the Ada part of the application may override signal handlers that were previously installed by either the system or by other user code.

If your application requires that either system or user signals be preserved, you need to instruct the Ada part not to install its own signal handler. You do this using `pragma Interrupt_State` that provides a general mechanism for overriding such uses of interrupts.

Additionally, you can use pragma `Interrupts_System_By_Default` to default all interrupts to System.

The set of interrupts for which the Ada run-time library sets a specific signal handler is the following:

- Ada.Interrupts.Names.SIGSEGV
- Ada.Interrupts.Names.SIGBUS
- Ada.Interrupts.Names.SIGFPE
- Ada.Interrupts.Names.SIGILL
- Ada.Interrupts.Names.SIGABRT

You can instruct the run-time library not to install its signal handler for a particular signal by using the configuration pragma `Interrupt_State` in the Ada code. For example:

    pragma Interrupt_State (Ada.Interrupts.Names.SIGSEGV, System);
    pragma Interrupt_State (Ada.Interrupts.Names.SIGBUS,  System);
    pragma Interrupt_State (Ada.Interrupts.Names.SIGFPE,  System);
    pragma Interrupt_State (Ada.Interrupts.Names.SIGILL,  System);
    pragma Interrupt_State (Ada.Interrupts.Names.SIGABRT, System);

Obviously, if the Ada run-time system cannot set these handlers it comes with the drawback of not fully preserving Ada semantics. `SIGSEGV`, `SIGBUS`, `SIGFPE` and `SIGILL` are used to raise corresponding Ada exceptions in the application, while `SIGABRT` is used to asynchronously abort an action or a task.