Skip to content

Commit

Permalink
[FIX] Process output writer thread/process lock fix and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
manneohlund committed Oct 2, 2017
1 parent 4831d7c commit 32d0c26
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions library/src/main/java/ashell/workers/ShellOutputStreamThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@
* Copyright © 2017 All rights reserved.
*/

/** todo old code, can be removed
DataOutputStream writer;
public void exec(List<String> commands) {
onShellStateChanged(State.BUSY);
if (writer == null) {
writer = new DataOutputStream(process.getOutputStream());
}
try {
writer.writeBytes(new String(StringUtils.listToString(commands).getBytes(Charset.forName("UTF-8"))));
writer.writeBytes("\n");
writer.flush();
} catch (Exception e) {
e.printStackTrace();
}
}
*/

public class ShellOutputStreamThread<T> extends Thread {
private Process process;
private OutputStream outputStream;
Expand All @@ -42,13 +25,11 @@ public ShellOutputStreamThread(Process process) {

@Override
public void run() {
synchronized (this) {
while (true) {
try {
this.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
while (true) {
try {
process.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Expand Down

0 comments on commit 32d0c26

Please sign in to comment.