diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/CHANGELOG.md | 11 | ||||
| -rw-r--r-- | core/replica.zig | 10 |
2 files changed, 16 insertions, 5 deletions
diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index faa02ade..e5d592bb 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -2,6 +2,17 @@ ## Unreleased +- An experiment, behind `PARDES_PAIR=1` until it is the default: `pardes + FILE` in a terminal and `pardes-gui FILE` fork a session with no + frontend of its own and are its first client. Such a session is kept + (started with `new --detach`, or a Detach typed in any client since) or + not: closing a client's window or terminal, or a TERM to it, ends a + session not kept when that was its last client; a client killed outright + leaves it running. `pardes ps` says `(tty, kept)` or `(tty)` of it. + Without the variable nothing changes, but a terminal client (`pardes + attach`) ended by a TERM now says goodbye and exits 0, its terminal put + back, where it died of the signal. + - `pardes new --detach[=NAME]` returns once the session runs (registered and listening), printing its name, exit 0; the session runs on in a session of its own. `pardes --detach=NAME` without `new` is still the diff --git a/core/replica.zig b/core/replica.zig index ff1e138e..1883e836 100644 --- a/core/replica.zig +++ b/core/replica.zig @@ -2059,10 +2059,10 @@ pub const Peers = struct { /// No frontend of its own (the host says): with no client either, the /// session is unattended. detached: bool = false, - /// Its last client left by closing its window, and no Detach was typed - /// in any (`kept`): a pair's session ends there (runtime/session.zig). + /// Its last client left with a close (its window closed, its terminal + /// hung up) and the session is a pair's not kept (daemon.sessionState): it + /// ends there (runtime/session.zig). closed: bool = false, - kept: bool = false, /// The worst a join cost the session's step, and the last one's dump. join_ns: u64 = 0, each_join: std.ArrayListUnmanaged(u64) = .empty, @@ -2362,7 +2362,7 @@ pub const Peers = struct { core.undrawn &= ~(@as(u8, 1) << @intCast(peer.view)); ps.closeViewOf(core, peer, peer.again); if (ps.count() == 0) core.unattended = ps.detached; - if (ps.count() == 0 and peer.close and !ps.kept) ps.closed = true; + if (ps.count() == 0 and peer.close and daemon.sessionState() == .pair) ps.closed = true; ps.seq += 1; ps.unit(0, ps.seq); ps.letGo(peer); @@ -2467,7 +2467,7 @@ pub const Peers = struct { /// (`left`), its last word; the client goes, and its reader says so. pub fn detach(ps: *Peers, k: u8) bool { for (ps.list) |slot| if (slot) |peer| if (peer.view == k) { - ps.kept = true; + daemon.keepSession(); var out: [wire.max_name + 8]u8 = undefined; peer.last(wire.encodeServer(&out, .{ .left = ps.name[0..@min(ps.name.len, wire.max_name)] }) catch unreachable); return true; |
