Package ghidra.pty.unix
Class UnixPtyChild
java.lang.Object
ghidra.pty.unix.UnixPtyEndpoint
ghidra.pty.unix.UnixPtyChild
- All Implemented Interfaces:
PtyChild
,PtyEndpoint
-
Nested Class Summary
Nested classes/interfaces inherited from interface ghidra.pty.PtyChild
PtyChild.Echo, PtyChild.TermMode
-
Field Summary
Fields inherited from class ghidra.pty.unix.UnixPtyEndpoint
fd, ioctls
-
Method Summary
Modifier and TypeMethodDescriptionStart a session without a real leader, instead obtaining the pty's namesession
(String[] args, Map<String, String> env, File workingDirectory, Collection<PtyChild.TermMode> mode) Spawn a subprocess in a new session whose controlling tty is this pseudo-terminalprotected PtySession
sessionUsingJavaLeader
(String[] args, Map<String, String> env, File workingDirectory, Collection<PtyChild.TermMode> mode) void
setWindowSize
(short cols, short rows) Resize the terminal window to the given width and height, in charactersMethods inherited from class ghidra.pty.unix.UnixPtyEndpoint
closeStreams, getInputStream, getOutputStream
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ghidra.pty.PtyChild
nullSession, session, session
Methods inherited from interface ghidra.pty.PtyEndpoint
getInputStream, getOutputStream
-
Method Details
-
nullSession
Description copied from interface:PtyChild
Start a session without a real leader, instead obtaining the pty's nameThis 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 interfacePtyChild
- Parameters:
mode
- the terminal mode. If a mode is not implemented, it may be silently ignored.- Returns:
- the file name
-
session
public PtySession session(String[] args, Map<String, String> env, File workingDirectory, Collection<PtyChild.TermMode> mode) throws IOExceptionSpawn a subprocess in a new session whose controlling tty is this pseudo-terminalThis method or
PtyChild.nullSession(Collection)
can only be invoked once per pty.- Specified by:
session
in interfacePtyChild
- Parameters:
args
- the image path and argumentsenv
- the environmentworkingDirectory
- the working directorymode
- 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- Implementation Notes:
- This uses
ProcessBuilder
to launch the subprocess. See its documentation for more details of the parameters of this method., This actually launches a special "leader" subprocess, which sets up the session and then executes the requested program. The requested program image replaces the leader so that the returned process is indeed a handle to the requested program. Ordinarily, this does not matter, but it may be useful to know when debugging. Furthermore, if special characters are sent on the parent before the image is replaced, they may be received by the leader instead. For example, Ctrl-C might be received by the leader by mistake if sent immediately upon spawning a new session. Users should send a simple command, e.g., "echo", to confirm that the requested program is active before sending special characters.
-
sessionUsingJavaLeader
protected PtySession sessionUsingJavaLeader(String[] args, Map<String, String> env, File workingDirectory, Collection<PtyChild.TermMode> mode) throws IOException- Throws:
IOException
-
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 interfacePtyChild
- Parameters:
cols
- the width in charactersrows
- the height in characters
-