From 1c11333717100ad7f85f5765faf9a95ae660d6ce Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Thu, 23 May 2024 16:19:38 +0200 Subject: [PATCH] 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. --- src/Tty.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Tty.zig b/src/Tty.zig index 48ff67b..b03dad8 100644 --- a/src/Tty.zig +++ b/src/Tty.zig @@ -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