diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 15:19:25 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 17:03:40 -0300 |
| commit | f2ede98aee0265e3506f5afd6039c70be7812767 (patch) | |
| tree | 284a64fc9fcf7ba777a20fad75cc6295d70695fb /src/main.zig | |
| parent | 08c9415dde1a1d5da2c20124c4fcd4c92783b290 (diff) | |
| download | pardes-f2ede98aee0265e3506f5afd6039c70be7812767.tar.gz pardes-f2ede98aee0265e3506f5afd6039c70be7812767.zip | |
remote clients: a pointer's hit carries the place it was made on (Layer.Place, on the wire, version 17) and a step resolves it from that, never from this process's frame (`surface`, `.local`), which a session never draws for a client: a window's pointer over a tag diverged it at once (the user's `tape byte 119`, 15 rejoins in 25 s) and a click there aborted it; a replay that meets a site its tape lacks, or makes a syscall that is none, is a divergence that goes on harmless (poisonOf), not a panic, and a speculation that makes one waits (Tty's shell lookup, untaped, is a value site now, as Shell's was); a copy over a queue is refused, not asserted; a session's last client, while no one else watches it, leaves it its layout (leaveView, settled as closeView is), which its rejoin copies; a redial waits only after an Upgrade's `refused` (a divergence's redialled a gone session 20 s); a dying session shuts its clients' links before its trace, and an --attach client ends its ssh and socket whatever way it exits; a far join's hashing stops at a blob once its client is let go (its leave waits for it in the step); a confirmed speculation's state is checked against its unit's digest, and the trace gives a key's and a pointer's words; test/daemon.py: 200 far joins level, a window's pointer swept over tags and body, ssh stand-in clients refused and detached, a client of a killed session ending in 2 s; in-process tests for each
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/src/main.zig b/src/main.zig index ada5f3b9..f9118dfc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -44,7 +44,10 @@ fn logFn( pub const panic = if (is_emscripten) std.debug.FullPanic(std.debug.defaultPanic) else std.debug.FullPanic(struct { fn call(msg: []const u8, ret_addr: ?usize) noreturn { - if (!recovering.swap(true, .seq_cst)) @import("vaxis").recover(); + if (!recovering.swap(true, .seq_cst)) { + pardes.replica.dying(); + @import("vaxis").recover(); + } @import("crash.zig").record(msg); std.debug.defaultPanic(msg, ret_addr); } @@ -54,7 +57,10 @@ var recovering: std.atomic.Value(bool) = .init(false); pub const debug = if (is_emscripten) struct {} else struct { pub fn handleSegfault(addr: ?usize, name: []const u8, opt_ctx: anytype) noreturn { - if (!recovering.swap(true, .seq_cst)) @import("vaxis").recover(); + if (!recovering.swap(true, .seq_cst)) { + pardes.replica.dying(); + @import("vaxis").recover(); + } return std.debug.defaultHandleSegfault(addr, name, opt_ctx); } }; @@ -883,6 +889,7 @@ fn nativeMain(std_init: std.process.Init) !void { } extern "c" fn execvp(file: [*:0]const u8, argv: [*:null]const ?[*:0]const u8) c_int; +extern "c" fn atexit(f: *const fn () callconv(.c) void) c_int; /// `pardes --ps`: what the per-user daemon keeps, as a tree; `--kill=<name>` /// and `--kill-all`: those sessions ended with their shells, a TERM and, @@ -1050,38 +1057,42 @@ fn remoteAttach(init: std.process.Init, opts: pardes.Options, where: []const u8, const pid = std.c.fork(); if (pid < 0) Say.no(io, "no fork for ssh", .{}); if (pid == 0) { + // A client killed outright takes its ssh with it. + daemon.hupOnStubDeath(true); const null_fd = std.c.open("/dev/null", .{ .ACCMODE = .RDONLY }, @as(std.c.mode_t, 0)); if (null_fd >= 0) _ = std.c.dup2(null_fd, 0); _ = execvp(argv[0].?, &argv); std.c._exit(127); } + // Ended at the client's exit, whatever path it takes there (its own + // words on a refused redial exit from inside it). ponytail: a client + // that crashes leaves its socket's file behind; its ssh goes. const Ssh = struct { var child: std.c.pid_t = 0; var path: [:0]const u8 = ""; - fn end() void { - _ = std.c.kill(child, .TERM); - _ = std.c.waitpid(child, null, 0); + fn end() callconv(.c) void { + if (child > 0) { + _ = std.c.kill(child, .TERM); + _ = std.c.waitpid(child, null, 0); + } _ = std.c.unlink(path); } }; Ssh.child = pid; Ssh.path = here; + _ = atexit(Ssh.end); var waited: u32 = 0; while (std.c.access(here, std.c.F_OK) != 0) : (waited += 1) { var status: c_int = 0; - if (std.c.waitpid(pid, &status, std.c.W.NOHANG) == pid) Say.no(io, "ssh to {s} ended before its forward was up", .{where}); - if (waited > 3000) { - Ssh.end(); - Say.no(io, "ssh to {s} set up no forward in 30 s", .{where}); + if (std.c.waitpid(pid, &status, std.c.W.NOHANG) == pid) { + Ssh.child = 0; + Say.no(io, "ssh to {s} ended before its forward was up", .{where}); } + if (waited > 3000) Say.no(io, "ssh to {s} set up no forward in 30 s", .{where}); const ts: std.c.timespec = .{ .sec = 0, .nsec = 10 * std.time.ns_per_ms }; _ = std.c.nanosleep(&ts, null); } - clientOf(init, opts, here, name, true) catch |err| { - Ssh.end(); - Say.no(io, "{t}", .{err}); - }; - Ssh.end(); + clientOf(init, opts, here, name, true) catch |err| Say.no(io, "{t}", .{err}); std.process.exit(0); } |
