JDK-4801027 : (process spec) Clarify need to invoke Process.destroy
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2003-01-09
  • Updated: 2010-11-18
Related Reports
Relates :  
Relates :  
Description
A program that creates many subprocesses should invoke Process.destroy in order
to ensure that all underlying resources are reclaimed.  This should be
mentioned in the spec of the Process class and of the Process.destroy method
itself.

-- ###@###.### 2003/1/9

Comments
EVALUATION See 6462165: (process) Preach Process file handle hygiene for an example of good Process cleanup. Yes, we should clarify that the OS-level subprocess may survive the garbage collection of the Process object and even the termination of the JVM itself.
09-10-2006

WORK AROUND static void closeStreams(Process p) throws IOException { p.getInputStream().close(); p.getOutputStream().close(); p.getErrorStream().close(); } Process p = ... try {...} // use p finally { closeStreams(p); p.destroy(); }
09-10-2006

EVALUATION Yes. -- ###@###.### 2003/1/9
01-11-0175