[kaffe] Pipes kept open after executing subprocesses
Ito Kazumitsu
ito.kazumitsu at mail.hidec.co.jp
Sun Jun 6 21:55:03 PDT 2004
Hi,
The attached program shows that some pipes used for executing subprocesses
are not closed when they are no longer needed. This will cause a
"too many open files" error in a long run.
I am afraid that FileDescriptor sync_fd in
libraries/javalib/kaffe/lang/UNIXProcess.java has something to do
with this problem.
import java.io.*;
public class TestProcess {
public static void main(String[] args) throws Exception {
for (int i=0; i < 10; i++) {
Process p = null;
InputStream pi = null;
InputStream pe = null;
OutputStream po = null;
try {
p = (Runtime.getRuntime()).exec(args);
pi = p.getInputStream();
po = p.getOutputStream();
pe = p.getErrorStream();
p.waitFor();
}
finally {
try {
if (pi != null) pi.close();
}
catch (Exception _) {}
try {
if (po != null) po.close();
}
catch (Exception _) {}
try {
if (pe != null) pe.close();
}
catch (Exception _) {}
}
}
while (true) {}
}
}
bash$ kaffe TestProcess sh -c 'echo a' &
[1] 3193
bash$ ls -al /proc/3193/fd
total 0
dr-x------ 2 ito ito 0 Jun 7 13:39 .
dr-xr-xr-x 3 ito ito 0 Jun 7 13:39 ..
lrwx------ 1 ito ito 64 Jun 7 13:39 0 -> /dev/pts/8
lrwx------ 1 ito ito 64 Jun 7 13:39 1 -> /dev/pts/8
l-wx------ 1 ito ito 64 Jun 7 13:39 13 -> pipe:[45332619]
l-wx------ 1 ito ito 64 Jun 7 13:39 14 -> pipe:[45332623]
l-wx------ 1 ito ito 64 Jun 7 13:39 15 -> pipe:[45332627]
l-wx------ 1 ito ito 64 Jun 7 13:39 16 -> pipe:[45332631]
l-wx------ 1 ito ito 64 Jun 7 13:39 17 -> pipe:[45332635]
l-wx------ 1 ito ito 64 Jun 7 13:39 18 -> pipe:[45332639]
l-wx------ 1 ito ito 64 Jun 7 13:39 19 -> pipe:[45332643]
lrwx------ 1 ito ito 64 Jun 7 13:39 2 -> /dev/pts/8
l-wx------ 1 ito ito 64 Jun 7 13:39 20 -> pipe:[45332647]
l-wx------ 1 ito ito 64 Jun 7 13:39 21 -> pipe:[45332651]
l-wx------ 1 ito ito 64 Jun 7 13:39 22 -> pipe:[45332655]
lr-x------ 1 ito ito 64 Jun 7 13:39 3 -> pipe:[45332614]
l-wx------ 1 ito ito 64 Jun 7 13:39 4 -> pipe:[45332614]
lr-x------ 1 ito ito 64 Jun 7 13:39 5 -> /home/ito/javatest/TestProcess.class
More information about the kaffe
mailing list