Skip to content

Commit 32d0c26

Browse files
committed
[FIX] Process output writer thread/process lock fix and cleanup
1 parent 4831d7c commit 32d0c26

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

library/src/main/java/ashell/workers/ShellOutputStreamThread.java

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@
1212
* Copyright © 2017 All rights reserved.
1313
*/
1414

15-
/** todo old code, can be removed
16-
DataOutputStream writer;
17-
public void exec(List<String> commands) {
18-
onShellStateChanged(State.BUSY);
19-
if (writer == null) {
20-
writer = new DataOutputStream(process.getOutputStream());
21-
}
22-
try {
23-
writer.writeBytes(new String(StringUtils.listToString(commands).getBytes(Charset.forName("UTF-8"))));
24-
writer.writeBytes("\n");
25-
writer.flush();
26-
} catch (Exception e) {
27-
e.printStackTrace();
28-
}
29-
}
30-
*/
31-
3215
public class ShellOutputStreamThread<T> extends Thread {
3316
private Process process;
3417
private OutputStream outputStream;
@@ -42,13 +25,11 @@ public ShellOutputStreamThread(Process process) {
4225

4326
@Override
4427
public void run() {
45-
synchronized (this) {
46-
while (true) {
47-
try {
48-
this.wait();
49-
} catch (InterruptedException e) {
50-
e.printStackTrace();
51-
}
28+
while (true) {
29+
try {
30+
process.waitFor();
31+
} catch (InterruptedException e) {
32+
e.printStackTrace();
5233
}
5334
}
5435
}

0 commit comments

Comments
 (0)