From: khaines@... Date: 2006-07-12T01:46:02+09:00 Subject: Re: Processes and Portability > I would like to run a process concurrently (thus if the process goes to > sleep or runs forever, I can still run other code from my main process) > and have all standard out of that process be put into a text file. I > would also like this code to be portable. And finally, I would like to > be able to kill this process at any time (So I will need the pid) > > This thus eliminates the use of fork. Also, I have tried: If you are doing the equivalent of fork/exec, here's some code that is in my IOWA package that will help. It depends on Daniel Berger's win32-process library, which can be found at RubyForge: http://rubyforge.org/projects/win32utils It, in turn, is dependent on window-pr, found at the same URL. This code has been tested on Linux and WinXP. You should be able to adapt it to your purposes. module IWATestSupport def self.create_process(args) @fork_ok = true unless @fork_ok == false pid = nil begin raise NotImplementedError unless @fork_ok unless pid = fork Dir.chdir args[:dir] exec(*args[:cmd]) end rescue NotImplementedError @fork_ok = false begin require 'rubygems' rescue LoadError end begin require 'win32/process' rescue LoadError raise "Please install win32-process." end cwd = Dir.pwd Dir.chdir args[:dir] pid = Process.create(:app_name => args[:cmd].join(' ')) Dir.chdir cwd end pid end end Kirk Haines