I can’t seem to make nested fork()s (granchildren processes) work with
the
win32::process module. Here’s my simple test script:
1 require “win32/process”
2
3 Process.fork do
4 $stdout.“child #{Process.pid}” ; $stdout.flush
5 2.times{
6 Process.fork do
7 $stdout.puts “sub-child #{Process.pid}” ; $stdout.flush
8 end
9 }
10 end
Output from my test script below gives:
Windows:
child 4384
Linux (using the “native” Process.fork, ie. skipping the require on line
1):
child 5126
sub-child 5127
sub-child 5128
If I comment out lines 6 and 8, I get an appropriate amount of output
from
windows (although, of course, always with the same PID). I’m not sure
if
this is a problem with win32::process, with the IO stream… or with
something else entirely?
On Windows, I’m running:
- WinXP SP2
- ruby 1.8.5 (2006-12-25 patchlevel 12) [i386-mswin32]
- win32-process (0.5.2, 0.5.1)
Thanks for any help!
Martin.