[SVN] Problem Detaching a Forked Process

Allan Odgaard throw-away-1 at macromates.com
Mon Apr 2 04:13:25 UTC 2007


On 1. Apr 2007, at 22:34, Adam Elliot wrote:

> I've been working on a bundle that needs to run a secondary command  
> in the background that sends updates to a nib file via tm_dialog  
> while the primary thread finishes up and displays a web page.   
> Although once the web page is displayed the secondary process  
> should remain active until the window open with tm_dialog -a is  
> closed.  The problem I'm having is when I do:
>
> pid = Process.fork do
> # Run the secondary process loop
> end
> Process.detach pid
>
> The primary process runs until I call TextMate.exit_show_html at  
> which point it appears to get stuck in a wait loop.  Unfortunately  
> this causes TextMate to hang.   Is their a way to have the primary  
> process not wait, but exit?

Yes, put STDOUT.close; STDERR.close in the top of your forked body.

Alternatively you could do something like (might be better when  
debugging):

     STDOUT.reopen open("/dev/console", "w")
     STDERR.reopen open("/dev/console", "w")




More information about the textmate-dev mailing list