summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorThomas Becker2012-05-10 11:04:47 (EDT)
committer Thomas Becker2012-05-10 11:04:47 (EDT)
commitd7fec350280da748be939e639fd5470a035842e3 (patch)
treee6e2bf117640c554d6dc7ebe1453e4c0b223e2ad
parent5687aa8beb51d2f347753cd9d9351c0d819664fb (diff)
downloadorg.eclipse.jetty.project-d7fec350280da748be939e639fd5470a035842e3.zip
org.eclipse.jetty.project-d7fec350280da748be939e639fd5470a035842e3.tar.gz
org.eclipse.jetty.project-d7fec350280da748be939e639fd5470a035842e3.tar.bz2
379116: start.jar fix to shutdown child processes with --exec. Remove finally block and replace with a shutdown hook in _exec if branch.refs/changes/16/5916/1
-rw-r--r--jetty-start/src/main/java/org/eclipse/jetty/start/Main.java29
1 files changed, 16 insertions, 13 deletions
diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
index 70fbe10..d4f503b 100644
--- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
+++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java
@@ -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();
-
- try
- {
- copyInThread(process.getErrorStream(),System.err);
- copyInThread(process.getInputStream(),System.out);
- copyInThread(System.in,process.getOutputStream());
- monitor.setProcess(process);
- process.waitFor();
- }
- finally
+ Runtime.getRuntime().addShutdownHook(new Thread()
{
- Config.debug("Destroying " + process);
- process.destroy();
- }
+ @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();
+
return;
}