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

David T. Lewis lewis at mail.msen.com
Mon Mar 14 10:30:34 UTC 2005


I'm afraid that I do not know a way to do this on Windows. I don't know the
right analog to unix signals for Win32, and I never put anything like this
into OSProcess for Windows (I know that Win32 has a mechanism for passing
console interrupts to a program, but I don't know how this should be done
for a program running as a service, etc).

As far as safety of the SIGHUP and SIGQUIT examples I suggested, I think
that this is a safe mechanism. I have tried sending multiple SIQQUIT signals
to Squeak from a shell script, and it still saves and exits correctly, so
it should be fairly robust. I cannot test on OS X though (I am using
Linux), so if you are running on that flavor of unix please test it
carefully.

One more thing I would suggest for a server: Add a check to make sure
you have adequate disk space before saving the image. Otherwise, it
would be possible to corrupt your image and changes files by trying to
write them to a file system that was out of space. This is of course
the case for saving a Squeak image anyway, but it seems like a good
safety check if you are setting this up to automatically save the
image in a server application.

Also, you should of course run the Squeak server under some user ID such
that only that user can kill the Squeak image by sending it a SIGQUIT or
SIGHUP.

Dave

On Sun, Mar 13, 2005 at 08:20:48PM -0500, Milan Zimmermann wrote:
> 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