Package org.eclipse.cdt.utils.pty
Class ConPTY
java.lang.Object
org.eclipse.cdt.utils.pty.ConPTY
A JNA implementation for ConPTY to provide a Windows native (as opposed to WinPTY)
implementation of a PTY.
This class should be accessed/created via the PTY class which will use ConPTY when it
is available.
- Restriction:
- This class is not intended to be referenced by clients.
-
Constructor Summary
ConstructorDescriptionConPTY()
Create a new Windows Pseudo Console (ConPTY) that an application can be attached to. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the entire PTY session.int
Executes the given process in the PTYint
getPID()
int
read
(byte[] buf) Implements contract ofInputStream.read(byte[])
void
setTerminalSize
(int width, int height) Implements the contract ofPTY.setTerminalSize(int, int)
, but throws exceptions that PTY logs.static com.sun.jna.Memory
toByteArray
(String[] envp) Convert envp to a byte array, encoding UTF_16LE.int
waitFor()
Implements the contract ofProcess.waitFor()
.void
write
(byte[] buf) Implements the contract ofOutputStream.write(byte[])
-
Constructor Details
-
ConPTY
Create a new Windows Pseudo Console (ConPTY) that an application can be attached to.- Throws:
IOException
-
-
Method Details
-
exec
Executes the given process in the PTY- Parameters:
cmdarray
- Command and arguments that will be quotes using standard Windows rules to make a command line. SeeWindowsArgumentQuoter
envp
-dir
-- Returns:
- the PID
- Throws:
IOException
-
toByteArray
Convert envp to a byte array, encoding UTF_16LE. Remember to pass CREATE_UNICODE_ENVIRONMENT to CreateProcess- Throws:
IOException
-
getPID
public int getPID() -
waitFor
public int waitFor()Implements the contract ofProcess.waitFor()
. This is used byPTY.waitFor(org.eclipse.cdt.utils.spawner.Spawner, int)
, but in the Spawner case the PID is passed around unnecessarily. This method therefore waits for the process it created only, like how Process#waitFor() behaves.- See Also:
-
close
Closes the entire PTY session. This will have the side effect of closing all the IO channels at once. The process will also be terminated when the console is closed if it isn't closed already. If the console's host (conhost) is closed then the process won't be automatically terminated. This happens if conhost crashes and the behaviour with winpty is the same in that case.- Throws:
IOException
-
read
Implements contract ofInputStream.read(byte[])
- Throws:
IOException
- See Also:
-
write
Implements the contract ofOutputStream.write(byte[])
- Throws:
IOException
- See Also:
-
setTerminalSize
Implements the contract ofPTY.setTerminalSize(int, int)
, but throws exceptions that PTY logs.- Throws:
IOException
- See Also:
-