[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Creating child processes in Windows?

Sonny Chee

2/3/2007 6:45:00 PM

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?

Sonny.

--
Posted via http://www.ruby-....

3 Answers

khaines

2/3/2007 7:03:00 PM

0

Ara.T.Howard

2/3/2007 9:12:00 PM

0

Joel VanderWerf

2/6/2007 7:06:00 PM

0

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