From 1e90694f91b258d5040f3400a9133cb77c211d02 Mon Sep 17 00:00:00 2001 From: ghidraffe <108089404+ghidraffe@users.noreply.github.com> Date: Wed, 11 Feb 2026 10:01:45 -0500 Subject: [PATCH] stop test from hanging during blocking method call. --- .../java/ghidra/pty/windows/ConPtyTest.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) 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 9fb6130572..55e64736f4 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 @@ -16,6 +16,7 @@ package ghidra.pty.windows; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; import static org.junit.Assume.assumeTrue; @@ -69,16 +70,28 @@ public class ConPtyTest extends AbstractPtyTest { writer.println("echo test"); 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, cmd.waitExited()); + assertFalse("Content read successfully from the cmd", t.isAlive()); } }