comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Ada and (SIGTERM?)
Date: Wed, 5 Aug 2009 18:06:22 -0700 (PDT)
Date: 2009-08-05T18:06:22-07:00	[thread overview]
Message-ID: <4244cbe7-1655-484b-a376-0237802ab37d@p10g2000prm.googlegroups.com> (raw)
In-Reply-To: 42c9446c-76d2-4c82-abab-fd7c5573d85e@k30g2000yqf.googlegroups.com

On Aug 5, 12:58 pm, Tomek Walkuski <tomek.walku...@gmail.com> wrote:
> Consider program with infinite loop, it simply acts as a server.
>
> How to kill it gracefully with housekeeping (finalization etc)?

I suppose "gracefully" precludes pulling the computer's plug out of
the wall?

If I understand, by the subject line, that this program is running on
some Unix-like system and you'd like the program to respond to a
signal and terminate gracefully: did you look at RM C.3?  It seems to
me you could set up an interrupt handler to catch SIGTERM and have it
set a global Boolean variable (make sure to use the Volatile pragma on
the variable), then instead of an "infinite" loop, make the loop
"while not Terminate loop" ... where Terminate is the global variable
that gets set by the interrupt handler.  The details depend on your
Ada implementation.  But that's one simple way to accomplish it.  No
doubt there are other ways, and probably better ones (e.g. the
interrupt handler, which must be a procedure in a protected object,
could set a Boolean in the protected object that controls a protected
entry in the object that could be used in a "select" statement, or
something like that).  In any case, C.3 is the place to start.

                                   -- Adam



  reply	other threads:[~2009-08-06  1:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-05 19:58 Ada and (SIGTERM?) Tomek Walkuski
2009-08-06  1:06 ` Adam Beneschan [this message]
2009-08-06 18:13   ` sjw
2009-08-06 18:48     ` Adam Beneschan
2009-08-06 19:30   ` Tomek Wałkuski
2009-08-06 19:57     ` Jeffrey R. Carter
2009-08-06 20:02       ` Tomek Wałkuski
2009-08-06 20:00     ` okellogg
2009-08-08 13:11     ` Tomek Wałkuski
2009-08-08 15:06       ` Maciej Sobczak
2009-08-08 17:53         ` Tomek Wałkuski
2009-08-16 13:11           ` Tomek Wałkuski
2009-08-16 15:47             ` Maciej Sobczak
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox