mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
termio: use host-spawn for pty
This commit is contained in:
15
src/Pty.zig
15
src/Pty.zig
@ -104,15 +104,12 @@ pub fn childPreExec(self: Pty) !void {
|
|||||||
if (setsid() < 0) return error.ProcessGroupFailed;
|
if (setsid() < 0) return error.ProcessGroupFailed;
|
||||||
|
|
||||||
// Set controlling terminal
|
// Set controlling terminal
|
||||||
// TODO: maybe
|
switch (std.os.system.getErrno(c.ioctl(self.slave, TIOCSCTTY, @as(c_ulong, 0)))) {
|
||||||
if (!@import("os/main.zig").isFlatpak()) {
|
.SUCCESS => {},
|
||||||
switch (std.os.system.getErrno(c.ioctl(self.slave, TIOCSCTTY, @as(c_ulong, 0)))) {
|
else => |err| {
|
||||||
.SUCCESS => {},
|
log.err("error setting controlling terminal errno={}", .{err});
|
||||||
else => |err| {
|
return error.SetControllingTerminalFailed;
|
||||||
log.err("error setting controlling terminal errno={}", .{err});
|
},
|
||||||
return error.SetControllingTerminalFailed;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can close master/slave pair now
|
// Can close master/slave pair now
|
||||||
|
@ -136,6 +136,7 @@ pub fn threadMain(self: *Thread) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn threadMain_(self: *Thread) !void {
|
fn threadMain_(self: *Thread) !void {
|
||||||
|
defer log.debug("renderer thread exited", .{});
|
||||||
tracy.setThreadName("renderer");
|
tracy.setThreadName("renderer");
|
||||||
|
|
||||||
// Run our thread start/end callbacks. This is important because some
|
// Run our thread start/end callbacks. This is important because some
|
||||||
@ -185,7 +186,7 @@ fn threadMain_(self: *Thread) !void {
|
|||||||
|
|
||||||
// Run
|
// Run
|
||||||
log.debug("starting renderer thread", .{});
|
log.debug("starting renderer thread", .{});
|
||||||
defer log.debug("exiting renderer thread", .{});
|
defer log.debug("starting renderer thread shutdown", .{});
|
||||||
_ = try self.loop.run(.until_done);
|
_ = try self.loop.run(.until_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,10 +365,7 @@ const Subprocess = struct {
|
|||||||
} else null;
|
} else null;
|
||||||
|
|
||||||
// Set our env vars
|
// Set our env vars
|
||||||
var env = if (internal_os.isFlatpak())
|
var env = try std.process.getEnvMap(alloc);
|
||||||
EnvMap.init(alloc)
|
|
||||||
else
|
|
||||||
try std.process.getEnvMap(alloc);
|
|
||||||
errdefer env.deinit();
|
errdefer env.deinit();
|
||||||
try env.put("TERM", "xterm-256color");
|
try env.put("TERM", "xterm-256color");
|
||||||
try env.put("COLORTERM", "truecolor");
|
try env.put("COLORTERM", "truecolor");
|
||||||
@ -397,17 +394,16 @@ const Subprocess = struct {
|
|||||||
var args = try std.ArrayList([]const u8).initCapacity(alloc, 8);
|
var args = try std.ArrayList([]const u8).initCapacity(alloc, 8);
|
||||||
defer args.deinit();
|
defer args.deinit();
|
||||||
|
|
||||||
try args.append("/usr/bin/flatpak-spawn");
|
// We use host-spawn so the PTY is setup properly.
|
||||||
try args.append("--host");
|
// future: rewrite host-spawn into pure Zig using dbus and
|
||||||
try args.append("--watch-bus");
|
// we can run this directly.
|
||||||
var env_it = env.iterator();
|
try args.append("/app/bin/host-spawn");
|
||||||
while (env_it.next()) |pair| {
|
try args.append("-pty");
|
||||||
try args.append(try std.fmt.allocPrint(
|
try args.append("-env");
|
||||||
alloc,
|
try args.append("TERM,COLORTERM");
|
||||||
"--env={s}={s}",
|
try args.append("/bin/sh");
|
||||||
.{ pair.key_ptr.*, pair.value_ptr.* },
|
try args.append("-l");
|
||||||
));
|
try args.append("-c");
|
||||||
}
|
|
||||||
try args.append(path);
|
try args.append(path);
|
||||||
|
|
||||||
break :args try args.toOwnedSlice();
|
break :args try args.toOwnedSlice();
|
||||||
@ -417,7 +413,7 @@ const Subprocess = struct {
|
|||||||
.arena = arena,
|
.arena = arena,
|
||||||
.env = env,
|
.env = env,
|
||||||
.cwd = opts.config.@"working-directory",
|
.cwd = opts.config.@"working-directory",
|
||||||
.path = if (internal_os.isFlatpak()) "/usr/bin/flatpak-spawn" else path,
|
.path = if (internal_os.isFlatpak()) args[0] else path,
|
||||||
.args = args,
|
.args = args,
|
||||||
.grid_size = opts.grid_size,
|
.grid_size = opts.grid_size,
|
||||||
.screen_size = opts.screen_size,
|
.screen_size = opts.screen_size,
|
||||||
|
@ -95,6 +95,7 @@ pub fn threadMain(self: *Thread) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn threadMain_(self: *Thread) !void {
|
fn threadMain_(self: *Thread) !void {
|
||||||
|
defer log.debug("IO thread exited", .{});
|
||||||
tracy.setThreadName("pty io");
|
tracy.setThreadName("pty io");
|
||||||
|
|
||||||
// Run our thread start/end callbacks. This allows the implementation
|
// Run our thread start/end callbacks. This allows the implementation
|
||||||
@ -109,7 +110,7 @@ fn threadMain_(self: *Thread) !void {
|
|||||||
|
|
||||||
// Run
|
// Run
|
||||||
log.debug("starting IO thread", .{});
|
log.debug("starting IO thread", .{});
|
||||||
defer log.debug("exiting IO thread", .{});
|
defer log.debug("starting IO thread shutdown", .{});
|
||||||
try self.loop.run(.until_done);
|
try self.loop.run(.until_done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user