tty: do not close /dev/tty on macos

Attempting to close /dev/tty may block indefinitely on macos if another
thread is already blocked on a read operation. As there is no practical
use for closing /dev/tty on exit besides unblocking other threads (which
does not work on macos anyway) we can just skip the close call.
This commit is contained in:
CJ van den Berg 2024-05-23 16:19:38 +02:00 committed by Tim Culverhouse
parent 55809160b9
commit 1c11333717

View file

@ -73,7 +73,8 @@ pub fn deinit(self: *Tty) void {
posix.tcsetattr(self.fd, .FLUSH, self.termios) catch |err| {
log.err("couldn't restore terminal: {}", .{err});
};
posix.close(self.fd);
if (builtin.os.tag != .macos) // closing /dev/tty may block indefinitely on macos
posix.close(self.fd);
}
/// stops the run loop