@Override public boolean isConnected() { return myProcess.isRunning(); }
public void run() { InputStream is = pty.getInputStream(); try { int ch; while (pty.isRunning() && (ch = is.read()) >= 0) { if (ch >= 0) { readChars.incrementAndGet(); } } } catch (Exception e) { e.printStackTrace(); } } };
public void run() { OutputStream os = pty.getOutputStream(); try { int ch; while (pty.isRunning() && (ch = System.in.read()) >= 0) { if (ch >= 0) { os.write(ch); os.flush(); } } } catch (Exception e) { e.printStackTrace(); } } };
public void run() { InputStream is = pty.getInputStream(); try { int ch; while (pty.isRunning() && (ch = is.read()) >= 0) { if (ch >= 0) { readChars.incrementAndGet(); } } } catch (Exception e) { e.printStackTrace(); } } };
public void run() { InputStream is = pty.getInputStream(); try { int ch; while (pty.isRunning() && (ch = is.read()) >= 0) { if (ch >= 0) { System.out.write(ch); System.out.flush(); } } latch.countDown(); } catch (Exception e) { e.printStackTrace(); } } };
t.start(); assertTrue("Child already terminated?!", pty.isRunning());
public void testExecCat() throws Exception { if (Platform.isWindows()) { return; } PtyProcess pty = new PtyProcessBuilder(new String[]{"cat"}).start(); Gobbler stdout = startReader(pty.getInputStream(), null); assertTrue("Process terminated unexpectedly", pty.isRunning()); pty.getOutputStream().write("Hello".getBytes(StandardCharsets.UTF_8)); pty.getOutputStream().flush(); Thread.sleep(1000); assertEquals("Hello", stdout.getOutput()); PtyHelpers.getInstance().kill(pty.getPid(), PtyHelpers.SIGPIPE); Thread.sleep(1000); assertTrue("Process is alive unexpectedly", !pty.isRunning()); assertEquals(PtyHelpers.SIGPIPE, pty.exitValue()); }