repos / zmx

session persistence for terminal processes
git clone https://github.com/neurosnap/zmx.git

commit
623494f
parent
a880a85
author
Eric Bower
date
2025-11-26 21:45:03 -0500 EST
chore: move code around
1 files changed,  +21, -21
M src/main.zig
+21, -21
 1@@ -42,27 +42,6 @@ const c = switch (builtin.os.tag) {
 2 
 3 var sigwinch_received: std.atomic.Value(bool) = std.atomic.Value(bool).init(false);
 4 
 5-fn handleSigwinch(_: i32, _: *const posix.siginfo_t, _: ?*anyopaque) callconv(.c) void {
 6-    sigwinch_received.store(true, .release);
 7-}
 8-
 9-fn setupSigwinchHandler() void {
10-    const act: posix.Sigaction = .{
11-        .handler = .{ .sigaction = handleSigwinch },
12-        .mask = posix.sigemptyset(),
13-        .flags = posix.SA.SIGINFO,
14-    };
15-    posix.sigaction(posix.SIG.WINCH, &act, null);
16-}
17-
18-fn getTerminalSize() ?ipc.Resize {
19-    var ws: c.struct_winsize = undefined;
20-    if (c.ioctl(posix.STDOUT_FILENO, c.TIOCGWINSZ, &ws) == 0) {
21-        return .{ .rows = ws.ws_row, .cols = ws.ws_col };
22-    }
23-    return null;
24-}
25-
26 const Client = struct {
27     alloc: std.mem.Allocator,
28     socket_fd: i32,
29@@ -882,3 +861,24 @@ pub fn getSocketPath(alloc: std.mem.Allocator, socket_dir: []const u8, session_n
30     @memcpy(fname[dir.len + 1 ..], session_name);
31     return fname;
32 }
33+
34+fn handleSigwinch(_: i32, _: *const posix.siginfo_t, _: ?*anyopaque) callconv(.c) void {
35+    sigwinch_received.store(true, .release);
36+}
37+
38+fn setupSigwinchHandler() void {
39+    const act: posix.Sigaction = .{
40+        .handler = .{ .sigaction = handleSigwinch },
41+        .mask = posix.sigemptyset(),
42+        .flags = posix.SA.SIGINFO,
43+    };
44+    posix.sigaction(posix.SIG.WINCH, &act, null);
45+}
46+
47+fn getTerminalSize() ?ipc.Resize {
48+    var ws: c.struct_winsize = undefined;
49+    if (c.ioctl(posix.STDOUT_FILENO, c.TIOCGWINSZ, &ws) == 0) {
50+        return .{ .rows = ws.ws_row, .cols = ws.ws_col };
51+    }
52+    return null;
53+}