close Unix file descriptor
Hi,
I have a process running to execute a command and it opens a file to read. The command will be run every minute, at some point it ran out file descriptor. How could I solve this problem? the code as below...
cmd = "generateTable -f prod.conf";
Process p = Runtime.getRuntime().exec(cmd);
how could I close the file descriptor in this case?
Any help will be much appreciated...
thanks.
[431 byte] By [
tvphana] at [2007-10-3 4:23:16]

Does the command execute in less than 1 minute? If it didn't, that would explain why the system runs out of file descriptors. Does the external command close the file? Again, another possibility. Finally, if everything is closing file descriptors correctly, and the command executes in a timely fashion, perhaps you actually need to increase the number of file descriptors available. Linux and i386 BSD use sysctl to change kernel parameters. Try 'man sysctl' on your system. If you don't have sysctl, well, I'm just out of ideas then.
Brian
Are you saying this external process "generateTable" is opening file descriptors but not closing them?
When the process terminates, any file descriptors it had still open (if any) should be closed automatically by the OS.
Either way, that external process is responsible for closing its own file descriptors that it uses though, and there's nothing your app can or should do about its failure to do so.
I think your problem lies elsewhere, in light of the 2nd paragraph above.