[racket] adding other objects to custodian

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Mon Jul 5 22:45:13 EDT 2010

Jakub Piotr Cłapa wrote at 07/05/2010 07:26 PM:
> On 04.07.10 04:03, Neil Van Dyke wrote:
>> I want to be sure that a host OS subprocess created with "subprocess" 
>> is killed when thread of my program in which it was created terminates.
>>
>> Currently, I create a custodian for the thread and explicitly call 
>> "custodian-shutdown-all" at the end of the thread's lifetime (in a 
>> "dynamic-wind" cleanup thunk).
>
> In my experience with Windows and UNIX I found that it is best to make 
> the subprocess die on stdin EOF or error. This automatically handles 
> dying ssh sessions (for remote processes) and dying racket. As a bonus 
> this probably is what you want (and what most truly UNIX programs do 
> themselves [1]).

Just so you know, I have a good reason.  The process in question is a 
number-crunching engine that can be many processes per hour, and needs 
special attention.  (In fact, increased stability is one of the reasons 
that I moved the code away from a C library and into its own host OS 
process, a la Google Chrome.)  I'm sure we can all think of scenarios 
with a number-crunching Unix process in which its EOF-handling code is 
insufficient.  Forcibly killing the process is the last of several 
things I do to be confident that the process will die when it's supposed 
to.  If not all processes die, even in event of other error, important 
production servers can fail.

This seems sensible to me.  And note that I do stop short of 
explosive-bolt interlocks and thermite. ;)

-- 
http://www.neilvandyke.org/


Posted on the users mailing list.