From: Qi Lu Date: 2008-07-15T04:38:41+09:00 Subject: Win32/Process when create a process, how to pass data I am working on moving a server code from Linux to Window XP. I need make original Process.fork call work on Windows XP. I tried two approaches: I have simplified the code. Approach 1: keep original fork method: require 'rubygems' require 'socket' require 'win32/process socket = TCPServer.new('localhost', 12345) pid = Process.fork {puts socket.inspect.to_s} Process.wait puts 'byb' when I run the script, it complained the ipaddr/port has been used, which we do not have problem with Linux. I need the TCPserver can be accessed by all subprocess. I tried make socket as global variable $socket. It does not work. Then I tried to use Process.create() with inherit set to true, like Approach 2: require 'rubygems' require 'socket' require 'win32/process' SERVER_OPTIONS = '-c' # indicate it will be a child process SUBPROC_NAME = '"C:\ruby\bin\ruby.exe" ' + '"-IC:/myworkspace/SSMSProject/Source/ruby" "' + File.expand_path($0) + '" ' + SERVER_OPTIONS if not ARGV.include?('-c') socket = TCPServer.new('localhost', 12345) pid = Process.create( :app_name => SUBPROC_NAME, :inherit => true ) else puts "hello from new process" puts socket.inspect.to_s end Process.wait puts 'byb' for this approach, I don't have problem to let it run. but the child process cannot access socket. I am new for Ruby with Win32. Can anyone help me? Thank you in advance! Qi BTW I installed win32-process (0.5.9) -- Posted via http://www.ruby-forum.com/.