OSProcess: making sure that a child process always dies

David T. Lewis lewis at mail.msen.com
Sun Mar 18 16:48:20 UTC 2007


Hi Josh,

I did some more work on this problem, and came up with a good
way to address it. You will need to build a new OSProcessPlugin
and load the latest OSProcess, after which you can do:

	OSProcess thisOSProcess killCurrentChildrenAtExit

This makes use of atexit() to arrange for any currently active child
processes to receive a SIGTERM signal when your Squeak VM exits,
regardless of whether the normal image #shutDown processing occurs.
By "currently active" I mean the child processes that have already
been started, and that are running at the time you do the
#killCurrentChildrenAtExit.

I also added primitives to support Unix setsid(), getpgid(), setpgid(),
getpgrp(), setpgrp() session management functions. You can use these
if you want to experiment further (but I think #killCurrentChildrenAtExit
is much easier).

The latest OSProcessPlugin and OSProcess are here:
 http://www.squeaksource.com/OSProcessPlugin/VMConstruction-Plugins-OSProcessPlugin-dtl.8.mcz 
 http://www.squeaksource.com/OSProcess/OSProcess-dtl.33.mcz

If you try this out, please let me know if it works for you.

Dave

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" :-)
> 
> I suppose that another option would be to stash the pids in a file  
> and kill them on startup.
> 
> 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.
> 
> Cheers,
> Josh
> 
> 
> On Mar 15, 2007, at 4:58 AM, David T. Lewis wrote:
> 
> >On Thu, Mar 15, 2007 at 12:15:01AM -0700, Joshua Gargus wrote:
> >>Hi,
> >>
> >>Is there a way to use OSProcess on OS X (or unix in general) to cause
> >>forked child processes to die when the parent Squeak process quits?
> >
> >You can keep track of the process proxy for the forked child
> >process, and explicitly terminate it when you exit Squeak, possibly
> >as part of a class #shutDown: method.
> >
> >For example, you can kill all child processes like this:
> >  OSProcess thisOSProcess allMyChildren do: [:e | e terminate]
> >
> >Dave
> >
> >
> 



More information about the Squeak-dev mailing list