Changeset 96
- Timestamp:
- 10/11/02 13:58:54 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/org/armedbear/j/RemoteShell.java
r88 r96 3 3 * 4 4 * Copyright (C) 2000-2002 Peter Graves 5 * $Id: RemoteShell.java,v 1. 2 2002-10-10 18:28:38piso Exp $5 * $Id: RemoteShell.java,v 1.3 2002-10-11 13:58:54 piso Exp $ 6 6 * 7 7 * This program is free software; you can redistribute it and/or … … 56 56 private void startProcess() 57 57 { 58 Process process = null; 58 59 try { 59 60 process = Runtime.getRuntime().exec("jpty " + shellCommand + " " + host); 60 } 61 catch (Throwable t) {} 62 if (process != null) { 63 startWatcherThread(); 64 // See if the process exits right away, meaning jpty couldn't launch the program. 65 try { 66 Thread.sleep(100); 67 } 68 catch (InterruptedException e) { 69 Log.error(e); 70 } 71 if (process == null) 72 return; 73 Property p; 74 switch (type) { 75 case TYPE_TELNET: 76 p = Property.TELNET_PROMPT_PATTERN; 77 break; 78 case TYPE_SSH: 79 p = Property.SSH_PROMPT_PATTERN; 80 break; 81 default: 82 p = null; 83 break; 84 } 85 if (p != null) 86 setPromptRE(Editor.preferences().getStringProperty(p)); 87 try { 88 stdin = new OutputStreamWriter(process.getOutputStream()); 89 stdoutThread = new StdoutThread(); 90 stderrThread = new StderrThread(); 91 stdoutThread.start(); 92 stderrThread.start(); 93 readOnly = false; 94 } 95 catch (Throwable t) { 96 Log.error(t); 97 } 61 setProcess(process); 62 } 63 catch (Throwable t) { 64 setProcess(null); 65 return; 66 } 67 startWatcherThread(); 68 // See if the process exits right away (meaning jpty couldn't launch 69 // the program). 70 try { 71 Thread.sleep(100); 72 } 73 catch (InterruptedException e) { 74 Log.error(e); 75 } 76 // When the process exits, the watcher thread calls setProcess(null), 77 // so check the value of getProcess() here. 78 if (getProcess() == null) 79 return; // Process exited. 80 Property property; 81 switch (type) { 82 case TYPE_TELNET: 83 property = Property.TELNET_PROMPT_PATTERN; 84 break; 85 case TYPE_SSH: 86 property = Property.SSH_PROMPT_PATTERN; 87 break; 88 default: 89 property = null; 90 break; 91 } 92 if (property != null) 93 setPromptRE(Editor.preferences().getStringProperty(property)); 94 try { 95 stdin = new OutputStreamWriter(process.getOutputStream()); 96 stdoutThread = new StdoutThread(process.getInputStream()); 97 stderrThread = new StderrThread(process.getErrorStream()); 98 stdoutThread.start(); 99 stderrThread.start(); 100 readOnly = false; 101 } 102 catch (Throwable t) { 103 Log.error(t); 98 104 } 99 105 } … … 103 109 RemoteShell remoteShell = new RemoteShell(type, host); 104 110 remoteShell.startProcess(); 105 if (remoteShell. process== null) {111 if (remoteShell.getProcess() == null) { 106 112 Editor.getBufferList().remove(remoteShell); 107 113 String program = null; … … 281 287 RemoteShell remoteShell = findRemoteShell(TYPE_TELNET, host); 282 288 if (remoteShell != null) { 283 if (remoteShell. process== null)289 if (remoteShell.getProcess() == null) 284 290 remoteShell.startProcess(); 285 291 } else … … 316 322 RemoteShell remoteShell = RemoteShell.findRemoteShell(TYPE_SSH, host); 317 323 if (remoteShell != null) { 318 if (remoteShell. process== null)324 if (remoteShell.getProcess() == null) 319 325 remoteShell.startProcess(); 320 326 } else
Note: See TracChangeset
for help on using the changeset viewer.