[squeak-dev] Squeak won't always quit

David T. Lewis lewis at mail.msen.com
Thu Oct 19 01:39:46 UTC 2017


On Wed, Oct 18, 2017 at 05:30:05PM -0400, Louis LaBrunda wrote:
> Hi,
> 
> I am running Squeak/Seaside headless on a Raspberry Pi Zero/W.  Almost everything works great.
> I want to be able to exit Squeak with a return code that I test in a shell script.  I was using
> this:
> 
> 	Smalltalk snapshot: false andQuitWithExitCode: 1.
> 
> to exit with a return code of 1.  This works some of the time but not always.  I can tell
> because the script logs the return code and when the exit doesn't work, there is nothing in the
> log.  It is still in Squeak/Seaside somewhere.
> 
> I took a look at #snapshot:andQuitWithExitCode: and #snapshot:andQuit:withExitCode:embedded:
> that it calls and found some code that I don't need, like code to save the image.
> 
> I wrote:
> 
> quickShutdown: exitCode
> 	"Shutdown without saving anything and exit with the exit code."
> 
> 	Object flushDependents.
> 	Object flushEvents.
> 	Smalltalk processShutDownList: true.
> 	self quitPrimitive: exitCode.
> 
> to simplify things but the problem persists.  That's not really a surprise as it should be all
> that was getting done before.  Does anyone have any ideas where it could be getting hung up?
> Maybe somewhere in Seaside?  Thanks for any ideas.

Hi Lou,

I think there is some clever shutdown code in #snapshot:andQuitWithExitCode:.
Maybe you care about that, and maybe you don't. And maybe it works reliably
and maybe it does not, I don't know.

But I do know that if you do "Smalltalk quitPrimitive: 7" it will definitely
exit, and the $? exit code that you see in the shell will be 7. So that may
be all that you need to do.

Note: The clever shutdown code is probably there to try to do a reasonable
cleanup for a Squeak image that might have open connections to a database session,
or some other resource then should be properly cleaned up before you kill the
Squeak VM process. Given that you a using a Raspberry Pi and that you want to
be able kill it reliably, you are probably not worried about database sessions
and that sort of thing. So just kill it and check exit status, and you should
be good to go.

Dave



More information about the Squeak-dev mailing list