OSProcess: making sure that a child process always dies
David T. Lewis
lewis at mail.msen.com
Fri Mar 16 00:54:41 UTC 2007
On Thu, Mar 15, 2007 at 11:12:01AM -0700, Joshua Gargus wrote:
> Hi David,
>
> Thanks, that's what I had implemented. However, the OS X VM has a
> menu item "Quit do not save" which appears not to go through the
> regular Squeak shutdown process. Also, you never know when you'll
> have to terminate an image with "extreme prejudice" :-)
Well, if you anticipate terminating Squeak with the "kill" command
(i.e. send a SIGTERM signal to the VM), then you can do this:
[OSProcess accessor forwardSigTerm wait.
OSProcess thisOSProcess allMyChildren
do: [:child | child isRunning ifTrue: [child terminate]].
SmalltalkImage current snapshot: false andQuit: true] fork
This will allow Squeak to catch the Unix SIGTERM signal, and
terminate your child processes before exiting.
> I suppose that another option would be to stash the pids in a file
> and kill them on startup.
Ick.
> Thanks to you and John for the suggestions. I'm not a unix expert,
> and I had no idea what support the underlying APIs had for this use
> case.
I was thinking that setpgrp() might do what you want, so I tried
adding this to OSPP, but it does not seem to behave quite as I
expected. I'll let you know if I figure something out.
Dave
More information about the Squeak-dev
mailing list
|