379116: start.jar fix to shutdown child processes with --exec. Remove finally block and replace with a shutdown hook in _exec if branch.
Change-Id: I85af53090a2797f433aca22276b413762999a477
This commit is contained in:
parent
5687aa8beb
commit
d7fec35028
|
@ -550,22 +550,25 @@ public class Main
|
||||||
if (_exec)
|
if (_exec)
|
||||||
{
|
{
|
||||||
CommandLineBuilder cmd = buildCommandLine(classpath,configuredXmls);
|
CommandLineBuilder cmd = buildCommandLine(classpath,configuredXmls);
|
||||||
|
|
||||||
ProcessBuilder pbuilder = new ProcessBuilder(cmd.getArgs());
|
ProcessBuilder pbuilder = new ProcessBuilder(cmd.getArgs());
|
||||||
final Process process = pbuilder.start();
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue