# Subprocessing with popen or popen3?

**URL:** <https://www.ruby-forum.com/t/subprocessing-with-popen-or-popen3/175729>\
**Category:** Ruby\
**Created:** [September 18, 2009, 3:59pm UTC](https://www.ruby-forum.com/t/subprocessing-with-popen-or-popen3/175729 "2009-09-18T15:59:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![revenantphoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@revenantphoenix](https://www.ruby-forum.com/u/revenantphoenix)\
**Post date:** [September 18, 2009, 3:59pm UTC](https://www.ruby-forum.com/t/subprocessing-with-popen-or-popen3/175729/1 "2009-09-18T15:59:59Z")

</div>

Currently I have a class MyServer that extends IO, and then I call:

server = MyServer.popen(COMMAND, 'r+)

The only problem is I need to separate stderr and stdout. I contemplated  
popen3, but I don’t see how I can make it associated with an object,  
which I need in the program. And in addition, it seems to lack a way to  
get the pid.

I could theoretically create the stderr, stdout and stdin within the  
MyServer class at initialization for popen3, but then I can’t use the  
pid to kill the process when I call the shutdown method. Any ideas?

---

<div class="post-metadata">

**Author:** ![revenantphoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@revenantphoenix](https://www.ruby-forum.com/u/revenantphoenix)\
**Post date:** [September 19, 2009, 5:24am UTC](https://www.ruby-forum.com/t/subprocessing-with-popen-or-popen3/175729/2 "2009-09-19T05:24:28Z")

</div>

You might find my framework “rexec” useful:

RExec [Orion Transfer Wiki]

More specifically:  
[RDOC]  
[http://gems.oriontransfer.org/doc\_root/rexec-1.1.6/rdoc/index.html](http://gems.oriontransfer.org/doc_root/rexec-1.1.6/rdoc/index.html)  
RExec::Task

rexec can help you make a daemon:  
RubyDNS and RExec Updates [Orion Transfer Wiki]

Kind regards,  
Samuel

---

<div class="post-metadata">

**Author:** ![revenantphoenix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/8edcca/32.png) [@revenantphoenix](https://www.ruby-forum.com/u/revenantphoenix)\
**Post date:** [September 19, 2009, 5:28am UTC](https://www.ruby-forum.com/t/subprocessing-with-popen-or-popen3/175729/3 "2009-09-19T05:28:34Z")

</div>

Thats odd, it seems like all the URLs were stripped out… 😕

[http://wiki.oriontransfer.org/code:rexec.git](http://wiki.oriontransfer.org/code:rexec.git)  
[http://wiki.oriontransfer.org/blog:](http://wiki.oriontransfer.org/blog:)  
2009:08:29:rubydns\_and\_rexec\_updates

Let me know more about what you are doing and I might be able to help.

Kind regards,  
Samuel
