mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
workaround for https://github.com/ziglang/zig/issues/13277
This commit is contained in:
12
src/Pty.zig
12
src/Pty.zig
@ -19,6 +19,12 @@ const c = switch (builtin.os.tag) {
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://github.com/ziglang/zig/issues/13277
|
||||||
|
// Once above is fixed, use `c.TIOCSCTTY`
|
||||||
|
const TIOCSCTTY = if (builtin.os.tag == .macos) 536900705 else c.TIOCSCTTY;
|
||||||
|
const TIOCSWINSZ = if (builtin.os.tag == .macos) 2148037735 else c.TIOCSWINSZ;
|
||||||
|
const TIOCGWINSZ = if (builtin.os.tag == .macos) 1074295912 else c.TIOCGWINSZ;
|
||||||
|
|
||||||
/// Redeclare this winsize struct so we can just use a Zig struct. This
|
/// Redeclare this winsize struct so we can just use a Zig struct. This
|
||||||
/// layout should be correct on all tested platforms.
|
/// layout should be correct on all tested platforms.
|
||||||
const winsize = extern struct {
|
const winsize = extern struct {
|
||||||
@ -64,7 +70,7 @@ pub fn deinit(self: *Pty) void {
|
|||||||
/// Return the size of the pty.
|
/// Return the size of the pty.
|
||||||
pub fn getSize(self: Pty) !winsize {
|
pub fn getSize(self: Pty) !winsize {
|
||||||
var ws: winsize = undefined;
|
var ws: winsize = undefined;
|
||||||
if (c.ioctl(self.master, c.TIOCGWINSZ, @ptrToInt(&ws)) < 0)
|
if (c.ioctl(self.master, TIOCGWINSZ, @ptrToInt(&ws)) < 0)
|
||||||
return error.IoctlFailed;
|
return error.IoctlFailed;
|
||||||
|
|
||||||
return ws;
|
return ws;
|
||||||
@ -72,7 +78,7 @@ pub fn getSize(self: Pty) !winsize {
|
|||||||
|
|
||||||
/// Set the size of the pty.
|
/// Set the size of the pty.
|
||||||
pub fn setSize(self: Pty, size: winsize) !void {
|
pub fn setSize(self: Pty, size: winsize) !void {
|
||||||
if (c.ioctl(self.master, c.TIOCSWINSZ, @ptrToInt(&size)) < 0)
|
if (c.ioctl(self.master, TIOCSWINSZ, @ptrToInt(&size)) < 0)
|
||||||
return error.IoctlFailed;
|
return error.IoctlFailed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +89,7 @@ pub fn childPreExec(self: Pty) !void {
|
|||||||
if (setsid() < 0) return error.ProcessGroupFailed;
|
if (setsid() < 0) return error.ProcessGroupFailed;
|
||||||
|
|
||||||
// Set controlling terminal
|
// Set controlling terminal
|
||||||
if (c.ioctl(self.slave, c.TIOCSCTTY, @as(c_ulong, 0)) < 0)
|
if (c.ioctl(self.slave, TIOCSCTTY, @as(c_ulong, 0)) < 0)
|
||||||
return error.SetControllingTerminalFailed;
|
return error.SetControllingTerminalFailed;
|
||||||
|
|
||||||
// Can close master/slave pair now
|
// Can close master/slave pair now
|
||||||
|
Reference in New Issue
Block a user