Joel VanderWerf
4/5/2007 7:21:00 PM
Gary Wright wrote:
>
> 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.
I agree with all of the above. What the win32 fork does is useful in its
own way, and it might even be useful to have something on unix/linux
that has the same semantics (fork/exec original script). But it needs a
different name...
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407