summaryrefslogtreecommitdiff
path: root/src/tty
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-29 12:32:23 -0300
committerGabriel Schneider <[email protected]>2026-10-29 13:11:16 -0300
commit6b89fed454fd56a3af4b576646538b45d3315146 (patch)
treef4be48c98368bc8c85c461af97528743afc98f59 /src/tty
parent34551a64366b3257ac577c5b68288f955c9eea80 (diff)
downloadpardes-6b89fed454fd56a3af4b576646538b45d3315146.tar.gz
pardes-6b89fed454fd56a3af4b576646538b45d3315146.zip
FreeBSD: the tty pardes builds for it and runs there, terminals, 9P and the daemon included
Cross-compiled with -Dtarget=x86_64-freebsd.15.0 (15 ships libutil.so.10; Zig's default 14.0 links .so.9) and run on the FreeBSD 15.1 box: - 9p_io serves there: fstatat, not Linux's statx. madvise is Linux's. - WINCH reaches the sigwait thread through a handler that does nothing: FreeBSD drops a signal ignored by default as it is sent. - A dead terminal answers a write with ENXIO, which std does not expect: a Debug build traced it to stderr, that same terminal, and recursed until the stack ran out (a session whose ssh dropped hung). No tracing there. - waitid's FreeBSD numbers and 64-bit id: a command pane's exit is seen. - No /proc: a shell's directory and program by sysctl, ttyTaken by the foreground group, the foreground job's name by its program. - File watching by FreeBSD 15's inotify. - ghostty's kitty loader: off Linux a stat comes before a t=f open (a FIFO hung it); FreeBSD's shm_open refuses O_NONBLOCK. - vaxis's test terminal has no read off Linux: no input thread for it. - test-install: the test-build programs installed into <prefix>/test, to run where the build cannot. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/tty')
-rw-r--r--src/tty/tty.zig10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig
index 37f66456..31f62d34 100644
--- a/src/tty/tty.zig
+++ b/src/tty/tty.zig
@@ -122,6 +122,8 @@ fn stopInput(loop: *Loop) void {
}
fn inputThread(loop: *Loop, cache: *vaxis.GraphemeCache) void {
+ // vaxis's test terminal reads nothing off Linux: it has no read at all.
+ if (comptime !@hasDecl(vaxis.Tty, "read")) return;
inputReader(loop, loop.tty, cache);
}
@@ -1185,6 +1187,10 @@ pub fn run(init: std.process.Init, opts: pardes.Options, term: Term) !void {
// Kept by a daemon, a hangup is the terminal's end, not the session's:
// winchWatch takes it, and the session carries on detached.
if (daemon.link >= 0) posix.sigaddset(&winch_set, posix.SIG.HUP);
+ // FreeBSD drops a signal whose action is to be ignored (WINCH's
+ // default) as it is sent, sigwait or not: a handler keeps it.
+ if (comptime builtin.os.tag == .freebsd)
+ posix.sigaction(.WINCH, &.{ .handler = .{ .handler = keepSignal }, .mask = posix.sigemptyset(), .flags = 0 }, null);
posix.sigprocmask(posix.SIG.BLOCK, &winch_set, null);
var tty_buf: [0x10000]u8 = undefined;
@@ -2450,7 +2456,7 @@ fn lspStatusSink(ctx: ?*anyopaque, text: []const u8) void {
}
fn watchFiles(io: std.Io, fd: c_int, loop: *Loop) anyerror!void {
- if (comptime builtin.os.tag != .linux) {
+ if (comptime builtin.os.tag != .linux and builtin.os.tag != .freebsd) {
while (file_watch.wait(fd)) loop.postEvent(.files_changed) catch break;
return;
}
@@ -2465,6 +2471,8 @@ fn watchFiles(io: std.Io, fd: c_int, loop: *Loop) anyerror!void {
}
}
+fn keepSignal(_: posix.SIG) callconv(.c) void {}
+
fn winchWatch(loop: *Loop, vx: *vaxis.Vaxis, tty: *vaxis.Tty) void {
var set = posix.sigemptyset();
posix.sigaddset(&set, posix.SIG.WINCH);