Skip to content

Commit a80d053

Browse files
committed
TerminalIO fixes
1 parent 523bf42 commit a80d053

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

vminitd/Sources/vminitd/TerminalIO.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ import ContainerizationOS
1919
import Foundation
2020
import Logging
2121
import SendableProperty
22+
#if canImport(Glibc)
2223
import Glibc
24+
#endif
2325

2426
final class TerminalIO: ManagedProcess.IO & Sendable {
25-
private let parent: Terminal? = nil
27+
private var parent: Terminal? = nil
2628
private let log: Logger?
2729

2830
private let stdio: HostStdio
@@ -59,7 +61,7 @@ final class TerminalIO: ManagedProcess.IO & Sendable {
5961
}
6062

6163
let hostFd = Glibc.syscall(Int(SYS_pidfd_getfd), containerFd, fd, 0)
62-
guard Foundation.close(Int32(containerFd)) != 0 else {
64+
guard Foundation.close(Int32(containerFd)) == 0 else {
6365
self.log?.error("failed to close pidfd: \(POSIXError.fromErrno())")
6466
}
6567

@@ -69,7 +71,7 @@ final class TerminalIO: ManagedProcess.IO & Sendable {
6971

7072
let fdDup = Int32(hostFd)
7173
self.parent = try Terminal(descriptor: fdDup, setInitState: false)
72-
try self.setupRelays(fd: fdDup)
74+
try setupRelays(fd: fdDup)
7375
}
7476

7577
private func setupRelays(fd: Int32) throws {

0 commit comments

Comments
 (0)