views:

38

answers:

2

I am basically asking the same question as http://stackoverflow.com/questions/2504445/spawn-a-background-process-in-ruby, except I need to spawn a background process in a Windows environment! Unfortunately, my research has revealed that Windows doesn't support Ruby forks (only spoons. Rimshot!).

+3  A: 

The win32-process library, part of the Win32Utils suite, is probably what you're after.

http://win32utils.rubyforge.org/

The win32-process library adds the Process.create and Process.fork methods for MS Windows. In add addition, it provides different implementations of the wait, wait2, waitpid, and waitpid2 methods. The Process.create method allows you to create native MS Windows processes using a variety of different configuration options.

The Process.fork implementation should be considered experimental and not used in production code.

Installation: gem install win32-process

Charles Roper
+1  A: 

Charles's answer is great. I also discovered that I can utilize Windows's start command as such:

system('start my_command')

This spawns a cmd window along with the process, which is undesirable in some circumstances. However, if this is tolerable, then you don't need the win32-process dependency :)

David Rivers