From b5bb3b373928f5967e50a1844e83a6f09549158b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 7 Aug 2023 21:10:11 -0700 Subject: [PATCH] termio/exec: if read thread gets 0 bytes then break the tight loop --- src/termio/Exec.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 85dd9a775..5e6cc2f3d 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -964,7 +964,10 @@ const ReadThread = struct { log.warn("read thread failed to set flags err={}", .{err}); log.warn("this isn't a fatal error, but may cause performance issues", .{}); }; - } else |_| {} + } else |err| { + log.warn("read thread failed to get flags err={}", .{err}); + log.warn("this isn't a fatal error, but may cause performance issues", .{}); + } // Build up the list of fds we're going to poll. We are looking // for data on the pty and our quit notification. @@ -1003,6 +1006,11 @@ const ReadThread = struct { } }; + // This happens on macOS instead of WouldBlock when the + // child process dies. To be safe, we just break the loop + // and let our poll happen. + if (n == 0) break; + // log.info("DATA: {d}", .{n}); @call(.always_inline, process, .{ ev, buf[0..n] }); }