From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: GNAT and SIGTERM (Linux x86_64)
Date: Tue, 26 Oct 2010 18:36:46 +0200
Date: 2010-10-26T18:36:46+02:00 [thread overview]
Message-ID: <op.vk6y3kwxule2fv@garhos> (raw)
In-Reply-To: 18db9616-3c2c-4dfa-8ef1-160e06c22b2d@c20g2000yqj.googlegroups.com
Le Tue, 26 Oct 2010 17:52:57 +0200, Bryan <brobinson.eng@gmail.com> a
écrit:
> I'm trying to capture SIGTERM in a very simple test program but I'm
> running into some issues. When I execute the code (at the end of
> message), I get the following output in my terminal when I send "kill -
> SIGTERM <PID>:
>
>> ./entry_point
> SIGTERM handler is NOT reserved
> !!! SIGTERM handler is NOT attached !!!
> Terminated
>
> [...]
> --------------------------------------
> Test program source code:
> --------------------------------------
> -- Signals.ads
> with Ada.Interrupts; use Ada.Interrupts;
> with Ada.Interrupts.Names; use Ada.Interrupts.Names;
> package Signals is
> pragma Unreserve_All_Interrupts;
> protected type Signal_Handler is
> procedure Handle_SIGTERM;
> pragma Attach_Handler(Handle_SIGTERM, SIGTERM);
> pragma Interrupt_State (SIGTERM, System);
> end Signal_Handler;
> end Signals;
>
> -- Signals.adb
> with Ada.Text_IO; use Ada.Text_IO;
> package body Signals is
> protected body Signal_Handler is
> procedure Handle_SIGTERM is
> begin
> Put_Line( "SIGTERM caught!" );
> end Handle_SIGTERM;
> end Signal_Handler;
> end Signals;
>
> -- Entrypoint.adb
> with Ada.Text_IO; use Ada.Text_IO;
> with Ada.Interrupts; use Ada.Interrupts;
> with Ada.Interrupts.Names; use Ada.Interrupts.Names;
> with Signals; use Signals;
>
> procedure Entry_Point is
> Shutdown_Flag : Boolean := False;
> begin
> if Is_Reserved(SIGTERM) then
> Put_Line("SIGTERM handler is reserved");
> else
> Put_Line("SIGTERM handler is NOT reserved");
> end if;
>
> if Is_Attached(SIGTERM) then
> Put_Line("SIGTERM handler is attached");
> else
> Put_Line("!!! SIGTERM handler is NOT attached !!!");
> end if;
>
> loop
> -- do nothing
> exit when Shutdown_Flag = True;
> end loop;
> end Entry_Point;
Signal_Handler is a type, and a type does not live on its own. To make it
“real”, you have to instantiate an entity of that type.
In few word : in Entry_Point, you forget to declare a variable of type
Signal_Handler.
Try this :
procedure Entry_Point is
Shutdown_Flag : Boolean := False;
Handler : Signal_Handler; -- < Add this line
begin
[... remaining of you cool stuff]
end Entry_Point;
It works :)
--
Si les chats miaulent et font autant de vocalises bizarres, c’est pas pour
les chiens.
next prev parent reply other threads:[~2010-10-26 16:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-26 15:52 GNAT and SIGTERM (Linux x86_64) Bryan
2010-10-26 16:36 ` Yannick Duchêne (Hibou57) [this message]
2010-10-27 7:43 ` Ludovic Brenta
2010-10-27 14:21 ` Bryan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox