Executing a program (a quick question)

Hi!

I want to launch a program and I don't care about its return value or
output. I also don't want it to block my ruby program.

On Linux I do this as follows:

  if !fork
    system("xpdf /path/to/some/file")
    exit!
    # ... or exec() ...
  end

But it doesn't work on MS-Windows... it complains that fork() isn't
implemented.

So how do I launch a program on MS-Windows without it blocking me and
without caring about its output and return status?

···

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

Albert Schlef wrote:

Hi!

I want to launch a program and I don't care about its return value or
output. I also don't want it to block my ruby program.

On Linux I do this as follows:

  if !fork
    system("xpdf /path/to/some/file")
    exit!
    # ... or exec() ...
  end

But it doesn't work on MS-Windows... it complains that fork() isn't
implemented.

So how do I launch a program on MS-Windows without it blocking me and
without caring about its output and return status?

You may use the win32-process gem that implements #fork as far as I
know, or simply IO.popen:

···

--------------------------------
IO.popen("your command")
#Just go on here
--------------------------------

Marvin

PS: On Linux I think the #spawn method does this task best.
--
Posted via http://www.ruby-forum.com/\.

Albert Schlef wrote:

Hi!

I want to launch a program and I don't care about its return value or
output. I also don't want it to block my ruby program.

On Linux I do this as follows:

  if !fork
    system("xpdf /path/to/some/file")
    exit!
    # ... or exec() ...
  end

But it doesn't work on MS-Windows... it complains that fork() isn't
implemented.

So how do I launch a program on MS-Windows without it blocking me and
without caring about its output and return status?

Thread.new do
   system("...")
end

This works on windows as well as platforms with fork.