# HG changeset patch # User Jaroslav Tulach # Date 1461731898 -7200 # Node ID 5b127bc8163e6c18c91465dec0b361154acddb7e # Parent 12a252145892058f5889796c9a74c6a97412511f Propagate the exit code to Mojo diff -r 12a252145892 -r 5b127bc8163e launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java --- a/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Wed Apr 27 06:14:49 2016 +0200 +++ b/launcher/fx/src/main/java/org/apidesign/bck2brwsr/launcher/BaseHTTPLauncher.java Wed Apr 27 06:38:18 2016 +0200 @@ -88,6 +88,7 @@ private CountDownLatch wait; private Thread flushing; private String rootPage; + private int exitCode; public BaseHTTPLauncher(String cmd) { this.cmd = cmd; @@ -463,7 +464,11 @@ @Override public void shutdown() throws IOException { + shutdown(0); + } + private void shutdown(int exitCode) throws IOException { synchronized (this) { + this.exitCode = exitCode; if (flushing != null) { flushing.interrupt(); flushing = null; @@ -607,6 +612,9 @@ LOG.log(Level.FINE, null, ex); } } + if (exitCode != 0) { + throw new IOException("Browser closed with exit code " + exitCode); + } } @Override @@ -902,7 +910,7 @@ public void service(Request request, Response response) throws Exception { final String exit = request.getParameter("exit"); if (exit != null) { - int exitCode = -1; + int exitCode; try { exitCode = Integer.parseInt(exit); } catch (NumberFormatException ex) { @@ -910,8 +918,7 @@ } if (exitCode != -1) { LOG.info("Exit request received. Shutting down!"); - shutdown(); - System.exit(exitCode); + shutdown(exitCode); } } if (request.getRequestURI().equals(vmResource)) {