# Win32::process and nested fork()s

**URL:** <https://www.ruby-forum.com/t/win32-process-and-nested-fork-s/88384>\
**Category:** Ruby\
**Created:** [March 10, 2007, 11:40am UTC](https://www.ruby-forum.com/t/win32-process-and-nested-fork-s/88384 "2007-03-10T11:40:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjcharl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ac91a4/32.png) [@mjcharl](https://www.ruby-forum.com/u/mjcharl)\
**Post date:** [March 10, 2007, 11:40am UTC](https://www.ruby-forum.com/t/win32-process-and-nested-fork-s/88384/1 "2007-03-10T11:40:26Z")

</div>

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.
