Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2012-05-22 11:57:41 +0000
committerGerrit Code Review @ Eclipse.org2012-05-22 11:57:41 +0000
commitc6c2e000ad3bacdd2191ccceeb85470d2ce5af39 (patch)
tree8d2e62930a0089e843b58a6c8c5423e405f7d54d
parente002fc4a5e1e9902558fb0ff89a78dac40c70ffb (diff)
parentd7fec350280da748be939e639fd5470a035842e3 (diff)
downloadorg.eclipse.jetty.project-c6c2e000ad3bacdd2191ccceeb85470d2ce5af39.tar.gz
org.eclipse.jetty.project-c6c2e000ad3bacdd2191ccceeb85470d2ce5af39.tar.xz
org.eclipse.jetty.project-c6c2e000ad3bacdd2191ccceeb85470d2ce5af39.zip
Merge "379116: start.jar fix to shutdown child processes with --exec. Remove finally block and replace with a shutdown hook in _exec if branch."
-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 70fbe1063f..d4f503b45e 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;
}

Back to the top