Executing a program (a quick question)

A

Albert Schlef

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?
 
M

Marvin Gülker

Albert said:
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:
 
J

Joel VanderWerf

Albert said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,158
Messages
2,570,882
Members
47,414
Latest member
djangoframe

Latest Threads

Top