I had a stranger problem yesterday at work concerning Java's class java.lang.Runtime. I started processes in a loop on a Linux machine, using Runtime.exec method. After a calling it for a couple hundred times I get java.io.IOException with the message "Too many open files".
According to Mike Noel, what happens is, that Runtime.exec opens 2 java.io.InputStream instances and 1 java.io.OutputStream instance. If you don't close them manually using the java.lang.Process instance returned from Runtime.exec call, they hang forever. As far as I understand the message "Too many open files" is returned cause Linux uses file descriptors for sockets (please correct me if I'm wrong).
{ by david linsin }
February 21, 2007
com_channels
- mail(dlinsin@gmail.com)
- jabber(dlinsin@gmail.com)
- skype(dlinsin)
my_links
recent_postings
loading...
8 comments:
Nice tip, although I can't see any info from Sun on runtime.exec() having a 'close' option. How did you close those streams?
Cheers
Steve
Well Runtime.exec returns an instance of java.lang.Process, which has methods to get the InputStream and OutputStream instances so that they can be closed.
see java.lang.Process
Thanks. That did the trick. I found some other documentation about process.destroy() closing all streams too. Apparently there was a problem prior to JRE 1.4 with p.destroy() killing the wrong linux process but that appears to be solved now according to sun's bug-track.
Cheers
Steve
Koxpcu
Güvercin
Timur taş Hoca
Aşçı Forum
Aşçı İş Arayanlar
Aşçı Arayanlar
Yerli Yemek Tarifleri
Aşçı Okulları
Dünya Global Mutfak
Profesyonel Yemek Malzemeleri
Profesyonel Sos çeşitleri
Tatlı Pasta Çeşitleri
Resturant Kurulumu
Yemek Üzerine İş yeri Kurulumu
Profesyonel Mutfak Malzemeleri
thanks for all information
bağcılar profilo servisi
bayrampaşa profilo servisi
bakırköy profilo servisi
avcılar ariston servisi
bağcılar ariston servisi
bahçelievler ariston servisi
bayrampaşa ariston servisi
beylikdüzü ariston servisi
Post a Comment