Skip to content

Commit

Permalink
Closing stdin stream so that the WinRM input reader thread stops when…
Browse files Browse the repository at this point in the history
… the process completes (fixes #87).
  • Loading branch information
Vincent Partington committed Feb 22, 2014
1 parent 21ffb52 commit 7c733bc
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ public OverthereProcess startProcess(final CmdLine cmd) {

final WinRmClient winRmClient = createWinrmClient();
try {
final PipedInputStream toCallersStdin = new PipedInputStream();
final PipedOutputStream callersStdin = new PipedOutputStream(toCallersStdin);
final PipedInputStream fromCallersStdin = new PipedInputStream();
final PipedOutputStream callersStdin = new PipedOutputStream(fromCallersStdin);
final PipedInputStream callersStdout = new PipedInputStream();
final PipedOutputStream toCallersStdout = new PipedOutputStream(callersStdout);
final PipedInputStream callersStderr = new PipedInputStream();
Expand All @@ -128,7 +128,7 @@ public void run() {
try {
byte[] buf = new byte[STDIN_BUF_SIZE];
for (; ; ) {
int n = toCallersStdin.read(buf);
int n = fromCallersStdin.read(buf);
if (n == -1)
break;
if (n == 0)
Expand Down Expand Up @@ -197,6 +197,7 @@ public synchronized int waitFor() {
outputReaderThread.join();
} finally {
winRmClient.deleteShell();
closeQuietly(callersStdin);
processTerminated = true;
}
if (outputReaderThreadException[0] != null) {
Expand All @@ -220,6 +221,7 @@ public synchronized void destroy() {

winRmClient.signal();
winRmClient.deleteShell();
closeQuietly(callersStdin);
processTerminated = true;
}

Expand Down

0 comments on commit 7c733bc

Please sign in to comment.