Squeak --headless - what is the correct signal to stop Squeak?

Milan Zimmermann milan.zimmermann at sympatico.ca
Mon Mar 14 01:20:48 UTC 2005


Dave, Thanks for your detail explanation - I am currently trying to achieve 
"quit on stop", and sounds like sending the SIGHUP should work without danger 
of loosing something (although perhaps me using your example and do 
#quitPrimitive would be more correct). As well, is there an equivalent way to 
register to "do this before quit" on Windows? 

Thanks Milan
On March 13, 2005 10:39 am, David T. Lewis wrote:
> I think you can pick any signal number you want. Either SIGQUIT or SIGHUP
> sound like reasonable choices.
>
> If you want to use (for example) the SIGQUIT signal to stop Squeak with an
> image save, here is what to do:
>
> 1) Load OSProcess. You need this for the signal forwarding.
>
> 2) Evaluate the following in your Squeak image:
>
>   [OSProcess accessor forwardSigQuit wait.
>   SmalltalkImage current snapshot: true andQuit: true]
>     fork name: 'SIGQUIT watcher'
>
> 3) From a Unix shell, "$ kill -3 <squeakpid>". Squeak will save itself,
> then exit.
>
> Explanation: The #forwardSigQuit method registers a Semaphore as an
> external object, and arranges for the VM to forward SIGQUIT signals to the
> Squeak Semaphore. A process in Squeak waits on that Semaphore and does an
> image save and exit when the Semaphore receives a signal.
>
> Also, you can easily disable any other signal, as long as Unix allows that
> signal to be handled. For example, if you want SIGHUP to be ignored, just
> evaluate:
>
>   OSProcess accessor forwardSigHup
>
> This causes all Unix SIGHUP signals to be forwarded to another Squeak
> Semaphore registered as another external object. The signals are gobbled
> up by the Squeak Semaphore, so effectively they are just ignored.
>
> Dave
>
> On Sun, Mar 13, 2005 at 12:35:59AM -0500, Milan Zimmermann wrote:
> > Hi,
> >
> > A related question - is there a "correct" signal to "stop" Squeak when
> > run as "init.d" service? I am running a Kom HTTP Server in headless mode
> > (start and stop using the attached script). Currently I use SIGHUP for
> > "STOP". While it works, I wonder if there is a more "correct" or "safe"
> > (in the sense of not loosing the image or whatever else could happen)
> > signal to use...
> >
> > Thanks Milan
> >
> > On March 12, 2005 12:14 pm, Brent Pinkney wrote:
> > > Hi,
> > >
> > > I have a Smallwiki image rnning headless.
> > >
> > > I stop this image using: kill <pid> which Ipresume sends a SIGKILL
> > > signal to the image.
> > >
> > > Is there a way the image can trap a signal and execute some Smalltalk
> > > code, like saving the image ?
> > >
> > > Thanks
> > >
> > > Brent




More information about the Squeak-dev mailing list