summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:07:59 -0300
committerGabriel Schneider <[email protected]>2026-11-05 09:54:56 -0300
commitf0eba0a5f07b88546cefe530f915302b203d0e6c (patch)
tree6547a202ad8af2cf3f553fb03402708f49d7f172 /src/gui/gui.zig
parent236c9f51134adf04932f7653ed0262a0c9253708 (diff)
downloadpardes-f0eba0a5f07b88546cefe530f915302b203d0e6c.tar.gz
pardes-f0eba0a5f07b88546cefe530f915302b203d0e6c.zip
upgrade: an Upgrade's dump and exec are upgrade.dumpInto and upgrade.execAs, which the terminal's and the window's upgradeNow each spelled out (the dump's path, the dump, its write, the old binary held, the daemon told, 9P flushed, the exec and what a failed one undoes); the dump is freed with the core's allocator, which made it, where each frontend freed it with its own after a failed exec (a panic there, never reached); writeDump and openSelf are upgrade.zig's own now
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig
index 3800c794..33922286 100644
--- a/src/gui/gui.zig
+++ b/src/gui/gui.zig
@@ -3749,24 +3749,7 @@ const Shell = struct {
var rec: upgrade.Record = .{ .link = daemon.link, .window = s.gui != null, .exe = path };
for (s.ptys, 0..) |slot, id| if (slot) |pt| if (pt.fd >= 0) rec.addPty(id, pt.pid, pt.fd);
var at_buf: [1024:0]u8 = undefined;
- const failed: []const u8 = failed: {
- const at = pardes.dump.upgradePath(&at_buf, core.settings.dump_dir.get()) orelse break :failed "Upgrade: no directory for the session's dump; this session stays as it is";
- const bytes = pardes.dump.dumpBytes(core) catch |err| {
- var words: [128]u8 = undefined;
- break :failed std.fmt.bufPrint(&why, "Upgrade: the session would not dump: {s}; it stays as it is", .{pardes.Messages.errorWords(err, &words)}) catch "Upgrade: the session would not dump";
- };
- defer s.gpa.free(bytes);
- if (!upgrade.writeDump(at, bytes)) break :failed std.fmt.bufPrint(&why, "Upgrade: the session's dump could not be written to {s}; it stays as it is", .{at[0..@min(at.len, 600)]}) catch "Upgrade: its dump could not be written";
- rec.dump = at;
- rec.old = upgrade.openSelf();
- daemon.upgraded();
- if (s.fs) |f| f.flushOut();
- const err_words = upgrade.exec(s.gpa, path, -1, &rec);
- // Still here: the exec failed.
- _ = libc.unlink(at);
- if (rec.old >= 0) _ = libc.close(rec.old);
- break :failed std.fmt.bufPrint(&why, "Upgrade: {s} would not start: {s}; this session stays as it is", .{ path[0..@min(path.len, 600)], err_words }) catch "Upgrade: the new pardes would not start";
- };
+ const failed = upgrade.dumpInto(core, &rec, &at_buf, &why) orelse upgrade.execAs(s.gpa, path, &rec, &at_buf, s.fs, &why);
// As it was: its ptys read on.
for (s.ptys, 0..) |*slot, id| if (slot.*) |*pt| if (pt.fd >= 0 and pt.reader == null) {
pt.reader = s.queue.startReader(.{ .handle = pt.fd, .flags = .{ .nonblocking = false } }, @intCast(id), s.gens[id]) catch null;