Conversation
|
Resolves: #175 |
This patch introduces two run overloads for spawning processes in PTY mode on Darwin and Linux
|
We decided to drop Windows support for now because until very recently (Windows 11 24H2), ConPTY did not support overlapped named pipes. This means we can't have async IO with ConPTY. |
Why omit the support, though? Could you just document the availability requirement and make it conditionally available given the right OS version? If we get actual Windows availability at some point, we could also stick |
|
Something like: guard ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 10, minorVersion: 0, patchVersion: 26100)) else {
// FIXME: Add `@available(Windows 10.0.26100, *)` to the relevant declarations once the compiler supports Windows availability.
preconditionFailure("PTY is not supported on this version of Windows.")
}Note that the actual availability syntax exists, compiler-rt just doesn't implement the versioning, so |
| } else if bytesRead == 0 || capturedErrno == EIO { | ||
| // We reached EOF. Return whatever's left | ||
|
|
||
| // On Linux, reading from a PTY parent returns EIO |
There was a problem hiding this comment.
| ) async throws -> SpawnPTYResult { | ||
| var termiosConfig = termios() | ||
| switch ptyOptions.terminalMode.storage { | ||
| case .cooked: |
There was a problem hiding this comment.
Is "cooked" really the technical term of art here?
| public struct PseudoterminalOptions: Sendable { | ||
| /// Terminal mode configuration. | ||
| /// | ||
| /// On Darwin/Linux, this controls the initial `termios` settings applied to the |
There was a problem hiding this comment.
Docs should say POSIX to be inclusive of BSDs
| public var windowSize: WindowSize { | ||
| get throws { | ||
| var result = winsize() | ||
| guard ioctl(self.parentDescriptor, UInt(TIOCGWINSZ), &result) == 0 else { |
There was a problem hiding this comment.
Can ioctl block for an indefinite amount of time for TIOCGWINSZ/TIOCSWINSZ?
|
Punting this for post 1.0 for now. We do want to support Windows |
This PR introduces PTY support to
Subprocesson Linux and Darwin. Now you can spawn processes in PTY mode with the two newrun()overloads.This API does NOT support Windows because Windows ConPTY did not support OVERLAPPED named pipes until
Windows 11 24H2.