diff options
author | Greg Wilkins | 2012-05-22 11:57:41 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2012-05-22 11:57:41 +0000 |
commit | c6c2e000ad3bacdd2191ccceeb85470d2ce5af39 (patch) | |
tree | 8d2e62930a0089e843b58a6c8c5423e405f7d54d | |
parent | e002fc4a5e1e9902558fb0ff89a78dac40c70ffb (diff) | |
parent | d7fec350280da748be939e639fd5470a035842e3 (diff) | |
download | org.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.java | 29 |
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; } |