Patch: close I/O channels when a process ends

David Daney ddaney@avtrex.com
Thu Aug 5 17:52:00 GMT 2004


Andrew Haley wrote:
> I ran out of file handles.  Was there any reason we weren't closing the
> files in Process.waitFor?
> 
> Andrew.
> 
> 
> 2004-08-04  Andrew Haley  <aph@redhat.com>
> 
> 	* java/lang/natPosixProcess.cc (waitFor): Close I/O channels.
> 
> Index: java/lang/natPosixProcess.cc
> ===================================================================
> RCS file: /cvs/gcc/gcc/libjava/java/lang/natPosixProcess.cc,v
> retrieving revision 1.18
> diff -c -2 -p -r1.18 natPosixProcess.cc
> *** java/lang/natPosixProcess.cc	1 Mar 2004 21:33:27 -0000	1.18
> --- java/lang/natPosixProcess.cc	4 Aug 2004 17:16:15 -0000
> *************** java::lang::ConcreteProcess::waitFor (vo
> *** 78,81 ****
> --- 78,105 ----
>       }
>   
> +   try
> +     {
> +       inputStream->close ();
> +     }
> +   catch (java::io::IOException *e)
> +     {
> +     }
> + 
> +   try
> +     {
> +       outputStream->close ();
> +     }
> +   catch (java::io::IOException *e)
> +     {
> +     }
> + 
> +   try
> +     {
> +       errorStream->close ();
> +     }
> +   catch (java::io::IOException *e)
> +     {
> +     }
> + 
>     return status;
>   }

Why?

David Daney.



More information about the Java-patches mailing list