+6
src/Loop.zig
+6
src/Loop.zig
···
301
if (@hasField(Event, "winsize")) {
302
return self.postEvent(.{ .winsize = winsize });
303
}
304
+
305
+
switch (builtin.os.tag) {
306
+
.windows => {},
307
+
// Reset the signal handler if we are receiving in_band_resize
308
+
else => self.tty.resetSignalHandler(),
309
+
}
310
},
311
}
312
},
+20
src/posix/Tty.zig
+20
src/posix/Tty.zig
···
23
var handler_mutex: std.Thread.Mutex = .{};
24
var handler_idx: usize = 0;
25
26
/// global tty instance, used in case of a panic. Not guaranteed to work if
27
/// for some reason there are multiple TTYs open under a single vaxis
28
/// compilation unit - but this is better than nothing
···
49
.flags = 0,
50
};
51
try posix.sigaction(posix.SIG.WINCH, &act, null);
52
53
const self: Posix = .{
54
.fd = fd,
···
67
};
68
if (builtin.os.tag != .macos) // closing /dev/tty may block indefinitely on macos
69
posix.close(self.fd);
70
}
71
72
/// Write bytes to the tty
···
23
var handler_mutex: std.Thread.Mutex = .{};
24
var handler_idx: usize = 0;
25
26
+
var handler_installed: bool = false;
27
+
28
/// global tty instance, used in case of a panic. Not guaranteed to work if
29
/// for some reason there are multiple TTYs open under a single vaxis
30
/// compilation unit - but this is better than nothing
···
51
.flags = 0,
52
};
53
try posix.sigaction(posix.SIG.WINCH, &act, null);
54
+
handler_installed = true;
55
56
const self: Posix = .{
57
.fd = fd,
···
70
};
71
if (builtin.os.tag != .macos) // closing /dev/tty may block indefinitely on macos
72
posix.close(self.fd);
73
+
}
74
+
75
+
/// Resets the signal handler to it's default
76
+
pub fn resetSignalHandler() void {
77
+
if (!handler_installed) return;
78
+
handler_installed = false;
79
+
var act = posix.Sigaction{
80
+
.handler = posix.SIG.DFL,
81
+
.mask = switch (builtin.os.tag) {
82
+
.macos => 0,
83
+
.linux => posix.empty_sigset,
84
+
.freebsd => posix.empty_sigset,
85
+
else => @compileError("os not supported"),
86
+
},
87
+
.flags = 0,
88
+
};
89
+
posix.sigaction(posix.SIG.WINCH, &act, null) catch {};
90
}
91
92
/// Write bytes to the tty