[racket] adding other objects to custodian
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]).
This is a problem with long-running, output-only programs (I wrote
several such programs for decoding unsolicited serial port data from
multimeters) but you can solve it by spawning a thread which hangs on
read() and calls exit() afterwards.
[1] DJB has some nice stories about "UNIX" daemons and their authors
funny ideas:
http://cr.yp.to/daemontools/faq/create.html#fghack
--
regards,
Jakub Piotr Cłapa