Source:
public TerminalServiceHostShell(ITerminalShell terminalShell, String initialWorkingDirectory, String commandToRun, String[] environment) { try { fTerminalShell = terminalShell; String encoding = fTerminalShell.getDefaultEncoding(); if (encoding != null) { fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell .getInputStream(), encoding)); } else { fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell .getInputStream())); } fBufReader.mark(1); fBufReader.read(); fBufReader.reset(); OutputStream outputStream = fTerminalShell.getOutputStream(); if (encoding != null) { Charset cs = Charset.forName(encoding); PrintWriter outputWriter = new PrintWriter( new OutputStreamWriter(outputStream, cs)); fShellWriter = new TerminalServiceShellWriterThread( outputWriter); } else { PrintWriter outputWriter = new PrintWriter(outputStream); fShellWriter = new TerminalServiceShellWriterThread( outputWriter); } fStdoutHandler = new TerminalServiceShellOutputReader(this, fBufReader, false, fShellWriter); fStderrHandler = new TerminalServiceShellOutputReader(this, null, true); int ttywait = getReadyPingMsec(); if (SHELL_INVOCATION.equals(commandToRun) && ttywait > 0) { doReadyPing("echo " + ECLIPSE_TEST_KEY + "'>'", ECLIPSE_TEST_KEY, ttywait, 10); } if (initialWorkingDirectory != null && initialWorkingDirectory.length() > 0 && !initialWorkingDirectory.equals(".") && !initialWorkingDirectory.equals("Command Shell") ) { writeToShell("cd " + PathUtility.enQuoteUnix(initialWorkingDirectory)); } if (SHELL_INVOCATION.equals(commandToRun)) { writeToShell(getPromptCommand()); } else if (commandToRun != null && commandToRun.length() > 0) { writeToShell(commandToRun); } } catch (Exception e) { e.printStackTrace(); if (fShellWriter != null) { fShellWriter.stopThread(); fShellWriter = null; } if (fStderrHandler != null) { fStderrHandler.interrupt(); fStderrHandler = null; } if (fStdoutHandler != null) { fStdoutHandler.interrupt(); fStdoutHandler = null; } } }

Target:
public TerminalServiceHostShell(ITerminalShell terminalShell, String initialWorkingDirectory, String commandToRun, String[] environment) { try { fTerminalShell = terminalShell; String encoding = fTerminalShell.getDefaultEncoding(); if (encoding != null) { fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell .getInputStream(), encoding)); } else { fBufReader = new BufferedReader(new InputStreamReader(fTerminalShell .getInputStream())); } fBufReader.mark(1); fBufReader.read(); fBufReader.reset(); OutputStream outputStream = fTerminalShell.getOutputStream(); if (encoding != null) { Charset cs = Charset.forName(encoding); PrintWriter outputWriter = new PrintWriter( new OutputStreamWriter(outputStream, cs)); fShellWriter = new TerminalServiceShellWriterThread( outputWriter); } else { PrintWriter outputWriter = new PrintWriter(outputStream); fShellWriter = new TerminalServiceShellWriterThread( outputWriter); } fStdoutHandler = new TerminalServiceShellOutputReader(this, fBufReader, false, fShellWriter); fStderrHandler = new TerminalServiceShellOutputReader(this, null, true); int pingMsec = getReadyPingMsec(); if (SHELL_INVOCATION.equals(commandToRun) && pingMsec > 0) { doReadyPing("echo " + ECLIPSE_TEST_KEY + "'>'", ECLIPSE_TEST_KEY, pingMsec, 10); } if (initialWorkingDirectory != null && initialWorkingDirectory.length() > 0 && !initialWorkingDirectory.equals(".") && !initialWorkingDirectory.equals("Command Shell") ) { writeToShell("cd " + PathUtility.enQuoteUnix(initialWorkingDirectory)); } if (SHELL_INVOCATION.equals(commandToRun)) { writeToShell(getPromptCommand()); } else if (commandToRun != null && commandToRun.length() > 0) { writeToShell(commandToRun); } } catch (Exception e) { e.printStackTrace(); if (fShellWriter != null) { fShellWriter.stopThread(); fShellWriter = null; } if (fStderrHandler != null) { fStderrHandler.interrupt(); fStderrHandler = null; } if (fStdoutHandler != null) { fStdoutHandler.interrupt(); fStdoutHandler = null; } } }