Class SshPtyChild

All Implemented Interfaces:
PtyChild, PtyEndpoint

public class SshPtyChild extends SshPtyEndpoint implements PtyChild
  • Constructor Details

    • SshPtyChild

      public SshPtyChild(com.jcraft.jsch.ChannelExec channel, OutputStream outputStream, InputStream inputStream)
  • Method Details

    • session

      public SshPtySession session(String[] args, Map<String,String> env, File workingDirectory, Collection<PtyChild.TermMode> mode) throws IOException
      Description copied from interface: PtyChild
      Spawn a subprocess in a new session whose controlling tty is this pseudo-terminal

      This method or PtyChild.nullSession(Collection) can only be invoked once per pty.

      Specified by:
      session in interface PtyChild
      Parameters:
      args - the image path and arguments
      env - the environment
      workingDirectory - the working directory
      mode - the terminal mode. If a mode is not implemented, it may be silently ignored.
      Returns:
      a handle to the subprocess
      Throws:
      IOException - if the session could not be started
    • nullSession

      public String nullSession(Collection<PtyChild.TermMode> mode) throws IOException
      Description copied from interface: PtyChild
      Start a session without a real leader, instead obtaining the pty's name

      This method or any other session method can only be invoked once per pty. It must be called before anyone reads the parent's output stream, since obtaining the filename may be implemented by the parent sending commands to its child.

      If the child end of the pty is on a remote system, this should be the file (or other resource) name as it would be accessed on that remote system.

      Specified by:
      nullSession in interface PtyChild
      Parameters:
      mode - the terminal mode. If a mode is not implemented, it may be silently ignored.
      Returns:
      the file name
      Throws:
      IOException - if the session could not be started or the pty name could not be determined
    • getInputStream

      public InputStream getInputStream()
      Description copied from interface: PtyEndpoint
      Get the input stream for this end of the pty

      Writes to the output stream of the opposite end arrive here, subject to the terminal's line discipline.

      Specified by:
      getInputStream in interface PtyEndpoint
      Overrides:
      getInputStream in class SshPtyEndpoint
      Returns:
      the input stream
    • getOutputStream

      public OutputStream getOutputStream()
      Description copied from interface: PtyEndpoint
      Get the output stream for this end of the pty

      Writes to this stream arrive on the input stream for the opposite end, subject to the terminal's line discipline.

      Specified by:
      getOutputStream in interface PtyEndpoint
      Overrides:
      getOutputStream in class SshPtyEndpoint
      Returns:
      the output stream
    • setWindowSize

      public void setWindowSize(short cols, short rows)
      Description copied from interface: PtyChild
      Resize the terminal window to the given width and height, in characters
      Specified by:
      setWindowSize in interface PtyChild
      Parameters:
      cols - the width in characters
      rows - the height in characters