From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,59929ddffbbb8400 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Path: g2news1.google.com!news4.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!193.201.147.68.MISMATCH!feeder.news-service.com!94.75.214.39.MISMATCH!aioe.org!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: GNAT and SIGTERM (Linux x86_64) Date: Tue, 26 Oct 2010 18:36:46 +0200 Organization: Ada @ Home Message-ID: References: <18db9616-3c2c-4dfa-8ef1-160e06c22b2d@c20g2000yqj.googlegroups.com> NNTP-Posting-Host: jdhycOtdR9nZrqmyI5Zlwg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 User-Agent: Opera Mail/10.63 (Win32) Xref: g2news1.google.com comp.lang.ada:14804 Date: 2010-10-26T18:36:46+02:00 List-Id: Le Tue, 26 Oct 2010 17:52:57 +0200, Bryan a = =C3=A9crit: > 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 : > >> ./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 :=3D 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 =3D True; > end loop; > end Entry_Point; Signal_Handler is a type, and a type does not live on its own. To make i= t = =E2=80=9Creal=E2=80=9D, 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 :=3D 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=E2=80=99es= t pas pour = les chiens.