ContainerizationOS: Alter Terminal.close() (#195)

Change to calling close on the underlying FileHandle as it already has
logic to set the fd to an invalid value and prevent double closes.
This commit is contained in:
Danny Canter
2025-07-03 10:44:01 -04:00
committed by GitHub
parent 8573b80fac
commit d3ca580a6d
+10 -1
View File
@@ -176,7 +176,16 @@ extension Terminal {
extension Terminal {
/// Close this pty's file descriptor.
public func close() throws {
try fromSyscall(Foundation.close(self.descriptor))
do {
// Use FileHandle's close directly as it sets the underlying fd in the object
// to -1 for us.
try self.handle.close()
} catch {
if let error = error as NSError?, error.domain == NSPOSIXErrorDomain {
throw POSIXError(.init(rawValue: Int32(error.code))!)
}
throw error
}
}
/// Reset the pty to its initial state.