Closing files opened with Open3.popen

F

Francis Hwang

Is there anyway to close a file that I opened with Open3.popen ? I'm
running a lot of external process (and capturing their stderr), but if
the process runs too long eventually I get a "Too many open files"
error.

Francis
 
A

Ara.T.Howard

Is there anyway to close a file that I opened with Open3.popen ? I'm running
a lot of external process (and capturing their stderr), but if the process
runs too long eventually I get a "Too many open files" error.

Francis

not sure i understand but:

~ > ruby -r open3 -e 'ios = Open3::popen3 "sh"; system "ps"; ios.map{|io| io.close}; system "ps"'

PID TTY TIME CMD
5379 pts/5 00:00:00 bash
6681 pts/5 00:00:00 ruby
6683 pts/5 00:00:00 sh
6684 pts/5 00:00:00 ps

PID TTY TIME CMD
5379 pts/5 00:00:00 bash
6681 pts/5 00:00:00 ruby
6685 pts/5 00:00:00 ps


-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it; and a weed grows, even though we do
| not love it. --Dogen
===============================================================================
 
P

Paul Brannan

Is there anyway to close a file that I opened with Open3.popen ? I'm
running a lot of external process (and capturing their stderr), but if
the process runs too long eventually I get a "Too many open files"
error.

Use IO#close.

Paul
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top