[squeak-dev] competition for SIGTERM

Chris Muller ma.chris.m at gmail.com
Sun Apr 26 23:57:51 UTC 2015


OSProcess provides the ability to set up and wait on any of several
semaphores which will be signaled if the VM process running the
current image gets a posix signal.

A few years ago I added a handler for SqueakSource's startUp: to set
up a response to TERM, like this:

restartSigTermHandler
SigTermHandler ifNotNil: [ SigTermHandler terminate ].
SigTermHandler :=
          [ OSProcess accessor restoreSigTerm.
          OSProcess accessor forwardSigTerm wait.
          SSRepository current log: 'SIGTERM received, shutting down
gracefully.'.
          self shutDown.
          Smalltalk snapshot: false andQuit: true ] newProcess
                name: 'Waiting for SIGTERM for graceful shutdown' ;
                resume

But now I want Magma servers to be able to respond similarly whether
SqueakSource is loaded in the same image or not.  But if I were to
introduce the above into Magma, then if SqueakSource was also loaded,
there would either be two processes waiting to shutdown or one of them
would run and the other wouldn't.

So this led me to ask, what is the best way to handle this in a
general fashion?  This is at the process level, so the first answer I
came up with was that it would make sense for the out-of-the-box
behavior to respond to TERM with a "Smalltalk snapshot: false andQuit:
true" so that each framework can do their own proper thing in
#shutDown:...   Is this a good idea or what is?


More information about the Squeak-dev mailing list