diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java index 72197b8d067..84fd4148ca4 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java @@ -18,6 +18,7 @@ * Noriaki Takatsu (IBM) - [220126] [dstore][api][breaking] Single process server for multiple clients * David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability * David McKnight (IBM) [250203] [dstore][shells]%var% is substituted to null in Unix shell + * David McKnight (IBM) [249715] [dstore][shells] Unix shell does not echo command *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.command; @@ -613,6 +614,9 @@ public class CommandMinerThread extends MinerThread writer.newLine(); writer.flush(); + // for bug 249715 - keeping track of time of last input + // in order know when to stop waiting for output + _stdOutputHandler.setTimeOfLastInput(System.currentTimeMillis()); if (!_isWindows && (input.startsWith("cd ") || input.equals("cd"))) //$NON-NLS-1$ //$NON-NLS-2$ { diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java index c289a0c86b5..efbd69186d8 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/OutputHandler.java @@ -14,6 +14,7 @@ * Contributors: * David McKnight (IBM) - [207178] changing list APIs for file service and subsystems * David McKnight (IBM) - [243699] [dstore] Loop in OutputHandler + * David McKnight (IBM) [249715] [dstore][shells] Unix shell does not echo command *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.command; @@ -53,6 +54,9 @@ public class OutputHandler extends Handler { private boolean _endOfStream = false; private List _encodings; + + // for bug 249715 + private long _timeOfLastInput = 0; public OutputHandler(DataInputStream reader, String qualifier, boolean isTerminal, boolean isStdError, boolean isShell, @@ -83,6 +87,9 @@ public class OutputHandler extends Handler { } + public void setTimeOfLastInput(long time){ + _timeOfLastInput = time; + } public void handle() { @@ -99,8 +106,9 @@ public class OutputHandler extends Handler { _commandThread.interpretLine(line, _isStdError); } - if (!_isTerminal) + if (!_isTerminal){ doPrompt(); + } _commandThread.refreshStatus(); } else { @@ -113,12 +121,11 @@ public class OutputHandler extends Handler { if ((_reader.available() == 0) && !_isStdError && _isShell) { if (!_isTerminal) { try { - Thread.sleep(500); + Thread.sleep(200); if (_reader.available() == 0) { // create fake prompt - _commandThread.createPrompt( - _commandThread.getCWD() + '>', - _commandThread.getCWD()); + String cwd = _commandThread.getCWD(); + _commandThread.createPrompt(cwd + '>', cwd); } } catch (Exception e) { } @@ -161,13 +168,28 @@ public class OutputHandler extends Handler { int lookahead = 0; - // redetermine available if none available now + // re-determine available if none available now if (available == 0) { - lookahead = _reader.read(); - if (lookahead == -1) { - return null; - } else { - available = _reader.available() + 1; + + if (!_isStdError && !_isTerminal){ + long lastInput = _timeOfLastInput; + while (lastInput == _timeOfLastInput && _keepRunning){ // once there's something new, we can stop waiting + Thread.sleep(500); // wait in case there is something + } + // it's possible that there is no output for something + // in the non-TTY case we need to prompt + available = checkAvailable(); + if (available == 0){ + return new String[0]; + } + } + else { + lookahead = _reader.read(); + if (lookahead == -1) { + return null; + } else { + available = _reader.available() + 1; + } } } @@ -203,7 +225,7 @@ public class OutputHandler extends Handler { try { String fullOutput = new String(readBytes, 0, numRead, encoding); - + // if output is not null, we assume the encoding was correct // and process the output if (fullOutput != null) {