# Executing a program (a quick question)

**URL:** <https://www.ruby-forum.com/t/executing-a-program-a-quick-question/186436>\
**Category:** Ruby\
**Created:** [April 7, 2010, 6:55am UTC](https://www.ruby-forum.com/t/executing-a-program-a-quick-question/186436 "2010-04-07T06:55:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [April 7, 2010, 6:55am UTC](https://www.ruby-forum.com/t/executing-a-program-a-quick-question/186436/1 "2010-04-07T06:55:36Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [April 7, 2010, 10:19am UTC](https://www.ruby-forum.com/t/executing-a-program-a-quick-question/186436/2 "2010-04-07T10:19:53Z")

</div>

Albert S. 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.

---

<div class="post-metadata">

**Author:** ![alby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/85f322/32.png) [@alby](https://www.ruby-forum.com/u/alby)\
**Post date:** [April 7, 2010, 5:23pm UTC](https://www.ruby-forum.com/t/executing-a-program-a-quick-question/186436/3 "2010-04-07T17:23:48Z")

</div>

Albert S. wrote:

> ```
> # ... 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.
