From: Gary Wright Date: 2007-04-06T04:13:09+09:00 Subject: Re: Forking and copying variables On Apr 5, 2007, at 2:54 PM, Joel VanderWerf wrote: > The source for win32/process makes it clear what is going on: > > cmd = 'ruby -I "' + $LOAD_PATH.join(File::PATH_SEPARATOR) << > '" "' > cmd << File.expand_path($PROGRAM_NAME) << '" ' << ARGV.join(' ') > cmd << ' child#' << @child_pids.length.to_s > > startinfo = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] > startinfo = startinfo.pack('LLLLLLLLLLLLSSLLLL') > procinfo = [0,0,0,0].pack('LLLL') > > rv = CreateProcess(0, cmd, 0, 0, 1, 0, 0, 0, startinfo, > procinfo) > > It runs the same ruby script again in another process. It's not > really fork in the unix sense. Thanks for clarifying things Joel. As I said, I'm not a Windows guy... Seems like a bad choice to use the name 'fork' for this behavior. It is more like a fork/exec of the original script (in Unix terminology). It would make more sense to me to have Process.fork fail with an exception on Windows and come up with a different name for this Windows-only behavior. The pseudo-portability of Ruby code has always seemed a bit odd to me. Obviously this sort of issue comes up with File IO, OS services, process and thread semantics and so on. I almost wish that the differences were more obvious via the class structure rather than methods of the same class having different semantics on different platforms. Gary Wright