mirror of
https://github.com/apple/container.git
synced 2026-11-15 10:20:00 +00:00
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:
1 parent
8573b80fac
commit
d3ca580a6d
1 file changed
+10
-1
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user