widgets(terminal): allow for always joining thread

Write an EOT into the tty stream so after killing the process we
*always* are able to join the thread. Maybe this is the very reason the
EOT control byte exists?
This commit is contained in:
Tim Culverhouse 2024-06-07 12:53:18 -05:00
parent f9d2fc7532
commit d36be9048c

View file

@ -89,6 +89,9 @@ pub fn deinit(self: *Terminal) void {
self.should_quit = true;
self.cmd.kill();
if (self.thread) |thread| {
// write an EOT into the tty to trigger a read on our thread
const EOT = "\x04";
_ = std.posix.write(self.pty.tty, EOT) catch {};
thread.join();
self.thread = null;
}