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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,e69505d5161d7d41,start X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!news2.euro.net!feeder.news-service.com!feeder.motzarella.org!news.motzarella.org!eternal-september.org!not-for-mail From: Reto Buerki Newsgroups: comp.lang.ada Subject: Interrupt handler and Ada.Real_Time.Timing_Events Date: Fri, 15 May 2009 18:26:12 +0200 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: news.eternal-september.org U2FsdGVkX19l3P3ngmqP7+O+xpFoZS5CN0htKZ0E66zWb+KbQkRc0c50gxL73d5WEupMxtsEQWNpaA0QrhsIybx3Hv+t1CNhN9K4OVjtH/MAH0xoh4cjU/ga4He68JK2L+U0P2m+wKQ= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Fri, 15 May 2009 16:26:10 +0000 (UTC) X-Auth-Sender: U2FsdGVkX188oZaduwhmAmUnOnDlv9ZupmrgszTMgOE= Cancel-Lock: sha1:kpV22yzOFiaTTWFDjtwzG4IkncE= User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) Xref: g2news2.google.com comp.lang.ada:5859 Date: 2009-05-15T18:26:12+02:00 List-Id: Hi, I hit a rather strange issue today mixing signal/interrupt handling with Ada.Real_Time.Timing_Events. We have a real life application where we use timing events but we also need a signal handler to catch signals from the environment (SIGTERM etc.). I wrote a small reproducer to illustrate the problem. The following protected object is used as an interrupt handler, which can be attached to a specific interrupt/signal: with Ada.Interrupts; package Handlers is protected type Signal_Handler (Signal : Ada.Interrupts.Interrupt_ID) is pragma Interrupt_Priority; entry Wait; private procedure Handle_Signal; pragma Attach_Handler (Handle_Signal, Signal); Occured : Boolean := False; end Signal_Handler; end Handlers; package body Handlers is protected body Signal_Handler is procedure Handle_Signal is begin Occured := True; end Handle_Signal; entry Wait when Occured is begin if Wait'Count = 0 then Occured := False; end if; end Wait; end Signal_Handler; end Handlers; The handler is used like this: with Ada.Text_IO; with Ada.Interrupts.Names; -- Uncommenting the next line breaks interrupt handler -- with Ada.Real_Time.Timing_Events; with Handlers; procedure Interrupt_Problem is use Ada.Interrupts; Handler : Handlers.Signal_Handler (Signal => Names.SIGTERM); begin if Is_Attached (Interrupt => Names.SIGTERM) then Ada.Text_IO.Put_Line ("Attached handler to SIGTERM"); else Ada.Text_IO.Put_Line ("Could not attach to SIGTERM!"); return; end if; Handler.Wait; Ada.Text_IO.Put_Line ("Interrupt received ..."); end Interrupt_Problem; As expected, when sending SIGTERM to the running 'Interrupt_Problem' process "Interrupt received ..." is displayed. So far so good. As commented in the source code, as soon as the Ada.Real_Time.Timing_Events package is with'ed, this mechanism breaks. The signal handler is not invoked any more when I send a SIGTERM signal to a running 'Interrupt_Problem' process, it just terminates without triggering the Handler.Wait. What could be the cause for this behavior? Is there a problem with this code? Thanks in advance! - reto