diff --git a/src/Pty.zig b/src/Pty.zig index 230aa67ff..c61c9feb9 100644 --- a/src/Pty.zig +++ b/src/Pty.zig @@ -104,15 +104,12 @@ pub fn childPreExec(self: Pty) !void { if (setsid() < 0) return error.ProcessGroupFailed; // Set controlling terminal - // TODO: maybe - if (!@import("os/main.zig").isFlatpak()) { - switch (std.os.system.getErrno(c.ioctl(self.slave, TIOCSCTTY, @as(c_ulong, 0)))) { - .SUCCESS => {}, - else => |err| { - log.err("error setting controlling terminal errno={}", .{err}); - return error.SetControllingTerminalFailed; - }, - } + switch (std.os.system.getErrno(c.ioctl(self.slave, TIOCSCTTY, @as(c_ulong, 0)))) { + .SUCCESS => {}, + else => |err| { + log.err("error setting controlling terminal errno={}", .{err}); + return error.SetControllingTerminalFailed; + }, } // Can close master/slave pair now diff --git a/src/renderer/Thread.zig b/src/renderer/Thread.zig index 12424272d..099c71cdf 100644 --- a/src/renderer/Thread.zig +++ b/src/renderer/Thread.zig @@ -136,6 +136,7 @@ pub fn threadMain(self: *Thread) void { } fn threadMain_(self: *Thread) !void { + defer log.debug("renderer thread exited", .{}); tracy.setThreadName("renderer"); // Run our thread start/end callbacks. This is important because some @@ -185,7 +186,7 @@ fn threadMain_(self: *Thread) !void { // Run log.debug("starting renderer thread", .{}); - defer log.debug("exiting renderer thread", .{}); + defer log.debug("starting renderer thread shutdown", .{}); _ = try self.loop.run(.until_done); } diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 1d3c1c195..61eb98d63 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -365,10 +365,7 @@ const Subprocess = struct { } else null; // Set our env vars - var env = if (internal_os.isFlatpak()) - EnvMap.init(alloc) - else - try std.process.getEnvMap(alloc); + var env = try std.process.getEnvMap(alloc); errdefer env.deinit(); try env.put("TERM", "xterm-256color"); try env.put("COLORTERM", "truecolor"); @@ -397,17 +394,16 @@ const Subprocess = struct { var args = try std.ArrayList([]const u8).initCapacity(alloc, 8); defer args.deinit(); - try args.append("/usr/bin/flatpak-spawn"); - try args.append("--host"); - try args.append("--watch-bus"); - var env_it = env.iterator(); - while (env_it.next()) |pair| { - try args.append(try std.fmt.allocPrint( - alloc, - "--env={s}={s}", - .{ pair.key_ptr.*, pair.value_ptr.* }, - )); - } + // We use host-spawn so the PTY is setup properly. + // future: rewrite host-spawn into pure Zig using dbus and + // we can run this directly. + try args.append("/app/bin/host-spawn"); + try args.append("-pty"); + try args.append("-env"); + try args.append("TERM,COLORTERM"); + try args.append("/bin/sh"); + try args.append("-l"); + try args.append("-c"); try args.append(path); break :args try args.toOwnedSlice(); @@ -417,7 +413,7 @@ const Subprocess = struct { .arena = arena, .env = env, .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, .grid_size = opts.grid_size, .screen_size = opts.screen_size, diff --git a/src/termio/Thread.zig b/src/termio/Thread.zig index 48dd4a35e..aa2a9c568 100644 --- a/src/termio/Thread.zig +++ b/src/termio/Thread.zig @@ -95,6 +95,7 @@ pub fn threadMain(self: *Thread) void { } fn threadMain_(self: *Thread) !void { + defer log.debug("IO thread exited", .{}); tracy.setThreadName("pty io"); // Run our thread start/end callbacks. This allows the implementation @@ -109,7 +110,7 @@ fn threadMain_(self: *Thread) !void { // Run log.debug("starting IO thread", .{}); - defer log.debug("exiting IO thread", .{}); + defer log.debug("starting IO thread shutdown", .{}); try self.loop.run(.until_done); }