Robert Klemme wrote: > 2006/3/8, Marcus Andersson <m-lists / bristav.se>: >> I have a long running process that I want to start from a Rails request. >> But, because it takes so long to execute, I want to start it in a >> separate process and then return. What is the best way to do that? > > You have several options - at leas these: > > - do it in a thread > > - create a new process using fork's block form, which executes the > block in the child > > - create a completely new process via a standard fork call > > Which one is best depends on the problem you are trying to solve, # of > CPU's available, personal taste etc. Portably, the following works, as long as you don't mind not having access to its stdin/out: t = Thread.new { system "something" } You can use t.value to wait for the process to finish and determine the result code of the system call (true or false). If you want to read/write to the process look into the various pipe openers: Kernel#open("|something"), Open3, etc. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407