Merge "379116: start.jar fix to shutdown child processes with --exec. Remove finally block and replace with a shutdown hook in _exec if branch."

This commit is contained in:
Greg Wilkins 2012-05-22 07:57:41 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit c6c2e000ad
1 changed files with 16 additions and 13 deletions

View File

@ -550,22 +550,25 @@ public class Main
if (_exec)
{
CommandLineBuilder cmd = buildCommandLine(classpath,configuredXmls);
ProcessBuilder pbuilder = new ProcessBuilder(cmd.getArgs());
final Process process = pbuilder.start();
Runtime.getRuntime().addShutdownHook(new Thread()
{
@Override
public void run()
{
Config.debug("Destroying " + process);
process.destroy();
}
});
copyInThread(process.getErrorStream(),System.err);
copyInThread(process.getInputStream(),System.out);
copyInThread(System.in,process.getOutputStream());
monitor.setProcess(process);
process.waitFor();
try
{
copyInThread(process.getErrorStream(),System.err);
copyInThread(process.getInputStream(),System.out);
copyInThread(System.in,process.getOutputStream());
monitor.setProcess(process);
process.waitFor();
}
finally
{
Config.debug("Destroying " + process);
process.destroy();
}
return;
}