Joel VanderWerf
2/6/2007 7:06:00 PM
Sonny Chee wrote:
> Hey Guys,
>
> Since fork is not implimented in Windows, how do you spawn subprocesses
> in Windows? Does anyone have a good (Cross Platform) solution besides
> Ruby Threads?
It can be as simple as this:
Thread.new do
system "myprogram.exe arg arg"
end
This doesn't block your ruby process, and the thread lives until the
program finishes. If you want the program to start and keep running
(possibly outliving the ruby process), just use this:
system "start myprogram.exe"
or, to open a file in an application:
system "start msword-file.doc"
(Hope I'm remembering that right, I'm not on windows now to test.)
This is not cross platform, but you can wrap it in something to make it so.
There is also a kinda-sorta fork in one of the win32 utils.
--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407