@SuppressWarnings("resource") // Do not close stdin 
	protected ExecInGdb execInGdb(String script) throws IOException {
		ProcessBuilder pb = new ProcessBuilder(gdbPath.toString());
		setPythonPath(pb);

		// If commands come from file, GDB will quit after EOF.
		Msg.info(this, "outFile: " + outFile);
		Msg.info(this, "errFile: " + errFile);
		pb.redirectInput(ProcessBuilder.Redirect.PIPE);
		pb.redirectOutput(outFile.toFile());
		pb.redirectError(errFile.toFile());
		Process gdbProc = pb.start();
		OutputStream stdin = gdbProc.getOutputStream();
		stdin.write(script.getBytes());
		stdin.flush();
		return new ExecInGdb(gdbProc, CompletableFuture.supplyAsync(() -> {
			try {
				if (!gdbProc.waitFor(TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
					Msg.error(this, "Timed out waiting for GDB");
					gdbProc.destroyForcibly();
					gdbProc.waitFor(TIMEOUT_SECONDS, TimeUnit.SECONDS);
					return new GdbResult(true, -1, Files.readString(outFile),
						Files.readString(errFile));
				}
				Msg.info(this, "GDB exited with code " + gdbProc.exitValue());
				return new GdbResult(false, gdbProc.exitValue(), Files.readString(outFile),
					Files.readString(errFile));
			}
			catch (Exception e) {
				return ExceptionUtils.rethrow(e);
			}
			finally {
				gdbProc.destroyForcibly();
			}
		}));
	}
Some snapshot likely to exceed the latest
Ghidra/Test/DebuggerIntegrationTest/src/test.slow/java/agent/gdb/rmi/AbstractGdbTraceRmiTest.java