Skip to content

Ghidra is a software reverse engineering (SRE) framework

fix another Pty windows test from hanging

ghidraffe9d6e233f6584
diff --git a/Ghidra/Framework/Pty/src/test/java/ghidra/pty/windows/ConPtyTest.java b/Ghidra/Framework/Pty/src/test/java/ghidra/pty/windows/ConPtyTest.java
index 55e64736f4..d85ab6bd8a 100644
--- a/Ghidra/Framework/Pty/src/test/java/ghidra/pty/windows/ConPtyTest.java
+++ b/Ghidra/Framework/Pty/src/test/java/ghidra/pty/windows/ConPtyTest.java
@@ -108,11 +108,29 @@ public class ConPtyTest extends AbstractPtyTest {
"echo This line is cleary much, much, much, much, much, much, much, much, much " +
" longer than 80 characters");
writer.flush();
- String line;
- do {
- line = reader.readLine();
- }
- while (!"test".equals(line));
+
+ // set up reading cmd output on a thread since "readLine" is blocking
+ Thread t = new Thread(() -> {
+ String line;
+ try {
+ do {
+ line = reader.readLine();
+ }
+ while (!"test".equals(line));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ });
+
+ t.setDaemon(true);
+ t.start();
+
+ writer.println("exit 3");
+ writer.flush();
+
+ assertEquals(3, gdb.waitExited());
+ assertFalse("Content read successfully from the cmd", t.isAlive());
}
}