mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-21 11:16:08 +03:00
termio: fix pty close error so close doesn't hang on macOS
This commit is contained in:
@ -429,12 +429,6 @@ const Subprocess = struct {
|
||||
/// Stop the subprocess. This is safe to call anytime. This will wait
|
||||
/// for the subprocess to end so it will block.
|
||||
pub fn stop(self: *Subprocess) void {
|
||||
// Close our PTY
|
||||
if (self.pty) |*pty| {
|
||||
pty.deinit();
|
||||
self.pty = null;
|
||||
}
|
||||
|
||||
// Kill our command
|
||||
if (self.command) |*cmd| {
|
||||
killCommand(cmd) catch |err|
|
||||
@ -443,6 +437,14 @@ const Subprocess = struct {
|
||||
log.err("error waiting for command to exit: {}", .{err});
|
||||
self.command = null;
|
||||
}
|
||||
|
||||
// Close our PTY. We do this after killing our command because on
|
||||
// macOS, close will block until all blocking operations read/write
|
||||
// are done with it and our reader thread is probably still alive.
|
||||
if (self.pty) |*pty| {
|
||||
pty.deinit();
|
||||
self.pty = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Resize the pty subprocess. This is safe to call anytime.
|
||||
@ -519,7 +521,10 @@ const ReadThread = struct {
|
||||
// gracefully shutting down.
|
||||
error.NotOpenForReading => log.info("io reader exiting", .{}),
|
||||
|
||||
else => log.err("READ ERROR err={}", .{err}),
|
||||
else => {
|
||||
log.err("io reader error err={}", .{err});
|
||||
unreachable;
|
||||
},
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
Reference in New Issue
Block a user