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

David T. Lewis lewis at mail.msen.com
Sun Mar 13 15:39:33 UTC 2005


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