diff -Nru nailgun-0.9.1/debian/changelog nailgun-0.9.1/debian/changelog --- nailgun-0.9.1/debian/changelog 2014-07-19 00:03:51.000000000 +0000 +++ nailgun-0.9.1/debian/changelog 2014-07-19 00:17:09.000000000 +0000 @@ -1,3 +1,16 @@ +nailgun (0.9.1-10~12.04) precise; urgency=low + + * Add upstream patch to fix exit status when stderr/stdout is closed + - See: https://github.com/martylamb/nailgun/commit/36733dd0629e7739ef440c8c14849bd1e0bc51cf + + -- Misty De Meo Fri, 18 Jul 2014 17:16:29 -0700 + +nailgun (0.9.1-9~14.04) trusty; urgency=low + + * Add trusty package + + -- Misty De Meo Fri, 18 Jul 2014 17:10:47 -0700 + nailgun (0.9.1-9~12.04) precise; urgency=low * Don't build javadoc diff -Nru nailgun-0.9.1/debian/patches/0003-close-stdout.patch nailgun-0.9.1/debian/patches/0003-close-stdout.patch --- nailgun-0.9.1/debian/patches/0003-close-stdout.patch 1970-01-01 00:00:00.000000000 +0000 +++ nailgun-0.9.1/debian/patches/0003-close-stdout.patch 2014-07-19 00:15:57.000000000 +0000 @@ -0,0 +1,104 @@ +From 36733dd0629e7739ef440c8c14849bd1e0bc51cf Mon Sep 17 00:00:00 2001 +From: Vladislav Hristov +Date: Mon, 10 Feb 2014 21:46:37 +0200 +Subject: [PATCH] Allow java classes to close stdout/stderr + +When the client calls a class, where either stdout or stderr is closed +the socket connection to the client is closed and no further data is +sent. This includes data transmitted over the other stream and exit +codes. +--- + .../com/martiansoftware/nailgun/examples/Exit.java | 5 ++- + .../martiansoftware/nailgun/NGOutputStream.java | 36 ++++++++++++++++++++++ + 2 files changed, 40 insertions(+), 1 deletion(-) + +Index: nailgun-0.9.1/nailgun-examples/src/main/java/com/martiansoftware/nailgun/examples/Exit.java +=================================================================== +--- nailgun-0.9.1.orig/nailgun-examples/src/main/java/com/martiansoftware/nailgun/examples/Exit.java 2014-03-12 11:12:47.000000000 -0700 ++++ nailgun-0.9.1/nailgun-examples/src/main/java/com/martiansoftware/nailgun/examples/Exit.java 2014-03-12 12:42:53.000000000 -0700 +@@ -27,7 +27,10 @@ + exitCode = Integer.parseInt(args[0]); + } catch (Exception e) {} + } ++ // Close stdout to test the exit code is returned properly ++ // even in such case ++ System.out.close(); + System.exit(exitCode); + } + +-} +\ No newline at end of file ++} +Index: nailgun-0.9.1/nailgun-server/src/main/java/com/martiansoftware/nailgun/NGOutputStream.java +=================================================================== +--- nailgun-0.9.1.orig/nailgun-server/src/main/java/com/martiansoftware/nailgun/NGOutputStream.java 2014-03-12 11:12:47.000000000 -0700 ++++ nailgun-0.9.1/nailgun-server/src/main/java/com/martiansoftware/nailgun/NGOutputStream.java 2014-03-12 12:42:53.000000000 -0700 +@@ -34,6 +34,7 @@ + + private final Object lock; + private byte streamCode; ++ private boolean closed = false; + + /** + * Creates a new NGOutputStream wrapping the specified +@@ -52,6 +53,7 @@ + * @see java.io.OutputStream.write(byte[]) + */ + public void write(byte[] b) throws IOException { ++ throwIfClosed(); + write(b, 0, b.length); + } + +@@ -59,6 +61,7 @@ + * @see java.io.OutputStream.write(int) + */ + public void write(int b) throws IOException { ++ throwIfClosed(); + byte[] b2 = {(byte) b}; + write(b2, 0, 1); + } +@@ -67,6 +70,7 @@ + * @see java.io.OutputStream.write(byte[],int,int) + */ + public void write(byte[] b, int offset, int len) throws IOException { ++ throwIfClosed(); + synchronized(lock) { + writeInt(len); + writeByte(streamCode); +@@ -74,4 +78,36 @@ + } + flush(); + } ++ ++ /** ++ * @see java.io.OutputStream.close() ++ * ++ * Implement an empty close function, to allow the client to close ++ * the stdout and/or stderr, without this closing the connection ++ * socket to the client. ++ */ ++ public void close() throws IOException { ++ throwIfClosed(); ++ closed = true; ++ } ++ ++ /** ++ * @see java.io.OutputStream.flush() ++ */ ++ public void flush() throws IOException { ++ throwIfClosed(); ++ super.flush(); ++ } ++ ++ /** ++ * Check if stream is closed and throw an IOException if yes. ++ * ++ * In the case of a public operation is being performed while the stream ++ * is already closed throws an IOException. ++ */ ++ private void throwIfClosed() throws IOException { ++ if(closed) { ++ throw new IOException(); ++ } ++ } + } diff -Nru nailgun-0.9.1/debian/patches/series nailgun-0.9.1/debian/patches/series --- nailgun-0.9.1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ nailgun-0.9.1/debian/patches/series 2014-07-19 00:16:03.000000000 +0000 @@ -0,0 +1 @@ +0003-close-stdout.patch