@@ -32,6 +32,7 @@ final class ManagedProcess: Sendable {
3232 private let syncfd : Pipe
3333 private let owningPid : Int32 ?
3434 private let ack : FileHandle
35+ private let terminal : Bool
3536
3637 private struct State {
3738 init ( io: IO ) {
@@ -54,6 +55,7 @@ final class ManagedProcess: Sendable {
5455 // swiftlint: disable type_name
5556 protocol IO {
5657 func start( ) throws
58+ func attach( pid: Int32 , fd: Int32 ) throws
5759 func closeAfterExec( ) throws
5860 func resize( size: Terminal . Size ) throws
5961 func close( ) throws
@@ -76,6 +78,7 @@ final class ManagedProcess: Sendable {
7678 Self . localizeLogger ( log: & log, id: id)
7779 self . log = log
7880 self . owningPid = owningPid
81+ self . terminal = stdio. terminal
7982
8083 let syncfd = Pipe ( )
8184 try syncfd. setCloexec ( )
@@ -133,7 +136,9 @@ extension ManagedProcess {
133136 try self . lock. withLock {
134137 log. debug ( " starting managed process " )
135138
136- try $0. io. start ( )
139+ if !self . terminal {
140+ try $0. io. start ( )
141+ }
137142
138143 // Start the underlying process.
139144 try process. start ( )
@@ -164,7 +169,10 @@ extension ManagedProcess {
164169 log. info ( " got back pid data \( i) , fd \( fd) " )
165170 $0. pid = i
166171
167- if let terminalIO = $0. io as? TerminalIO , fd != - 1 {
172+ if self . terminal {
173+ guard fd != - 1 else {
174+ throw ContainerizationError ( . internalError, message: " vmexec did not return pty fd " )
175+ }
168176 try terminalIO. attach ( pid: i, fd: fd)
169177 }
170178
0 commit comments