On Wed, Oct 08, 2003 at 12:00:50PM +0900, Ariff Abdullah wrote:
> # ruby -e 'a = Thread.new { fork {} }; a.join' 
> -e:1: warning: fork terminates thread at -e:1
> # ruby -v
> ruby 1.8.0 (2003-10-05) [i386-freebsd4]
> 
> is this intentional?


  Hello!

I don't know, but I have the same warning, if I make a
fork{} in the main thread, and there is one or more
other running thread.

% vi thread.rb
 1.:   #!/usr/bin/ruby -w
 2.:   
 3.:   def forkAndWaitInThread
 4.:           Kernel.fork {
 5.:                   Kernel.exec("sleep 5")
 6.:           }
 7.:           Thread.new {
 8.:                   Process.wait
 9.:           }
10.:   end
11.:   
12.:   2.times { forkAndWaitInThread }
13.:   
14.:   Thread.list.each { |t| t.join unless t == Thread.current }
15.:   

% chmod +x thread.rb ; ./thread.rb
./thread.rb:4: warning: fork terminates thread at ./thread.rb:8

Seems to work as I expected, but warnings make me misgiving.
Could somebody explain me the reasons?  Am I doing wrong
if I leave out of consideration this warning?  What is
the correct/usual method to execute processes in background?

% ruby -v
ruby 1.8.0 (2003-10-05) [i386-linux]
		...from Debian/sid package

-- 
bSanyI