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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b42257070cad7d43 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-03-17 01:38:53 PST Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.slurp.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Handling signals in ADA References: <3AADFFCF.691F1F8@labe.felk.cvut.cz> <87y9u6k7s6.fsf@deneb.enyo.de> Organization: Multimedia X-Newsreader: trn 4.0-test72 (19 April 1999) From: cts@kampong.aedinc.net ((null)) Message-ID: Date: Fri, 16 Mar 2001 03:06:09 GMT NNTP-Posting-Host: 208.4.231.188 X-Trace: newsfeed.slurp.net 984711969 208.4.231.188 (Thu, 15 Mar 2001 21:06:09 CDT) NNTP-Posting-Date: Thu, 15 Mar 2001 21:06:09 CDT Xref: nntp.stanford.edu comp.lang.ada:91502 Date: 2001-03-16T03:06:09+00:00 List-Id: In article <87y9u6k7s6.fsf@deneb.enyo.de>, Florian Weimer wrote: >Tomas Hlavaty writes: > >> Hi, could you help me with translating following C code to ADA? > > >The standard Ada library does not support signals. Typical Ada >programs use other communication mechanisms, Yes, but typical Unix programs use signals. Florist will have what you want. You can find those at ftp://ftp.cs.fsu.edu/pub/PART Alternatively if you're using the gnat compiler you can the facilities in Ada.Interrupts. Here's an example- -- cut here -- with Ada.Text_IO; use Ada.Text_IO; with Ada.Interrupts.names; with Interrupt_Handler; use Interrupt_Handler; pragma Unreserve_All_Interrupts; procedure When_Is_It_Over is Fat_Lady: Singer(Ada.Interrupts.Names.SIGINT); begin loop New_Line; delay 1.0; Put("It ain't over..."); exit when Fat_Lady.Sings; end loop; Put_Line(" until the fat lady sings."); end When_Is_It_over; -- cut here -- with Ada.Interrupts; package Interrupt_Handler is protected type Singer (Id: Ada.Interrupts.Interrupt_Id) is function Sings return Boolean; procedure Handler; pragma Attach_Handler(Handler, Id); private Done: Boolean := False; end Singer; end; -- cut here -- package body Interrupt_Handler is protected body Singer is function Sings return Boolean is begin return Done; end Sings; procedure handler is begin done := True; end handler; end Singer; end; -- ======================================================================= Life is short. | Craig Spannring Bike hard, ski fast. | cts@internetcds.com --------------------------------+------------------------------------