summaryrefslogtreecommitdiff
path: root/runtime/session.zig
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/session.zig')
-rw-r--r--runtime/session.zig14
1 files changed, 13 insertions, 1 deletions
diff --git a/runtime/session.zig b/runtime/session.zig
index 64846319..e4eb0300 100644
--- a/runtime/session.zig
+++ b/runtime/session.zig
@@ -100,9 +100,14 @@ pub fn Loop(comptime Frontend: type) type {
l.host = try fe.open(&l);
defer fe.close(&l);
+ daemon.notesTo(&l, note);
defer l.peers.deinit();
// Before the core goes: each client sees its link end.
defer l.peers.dropAll(l.core);
+ // A first client on the socket it was started with, before its
+ // first effects: it has every terminal from its first byte, and
+ // no reload (Core.openView).
+ if (o.pair) |fd| l.peers.join(l.core, .{ .fd = fd });
l.effects();
// ...and its shells, once a fresh session's own has a directory
// to adopt them in.
@@ -113,12 +118,17 @@ pub fn Loop(comptime Frontend: type) type {
l.ptys.start(l.core);
l.watches.start();
try fe.start(&l);
+ // A `new --detach`'s launch returns now.
+ daemon.launched();
while (!l.core.quit) {
pardes.turn.bump(&pardes.turn.restores);
try l.core.pump(l.host);
// Its unit to each replica client, and theirs taken in.
l.peers.boundary(l.core);
+ // A pair's session with no daemon ends with its last link:
+ // nothing could attach to it again.
+ if (o.pair != null and daemon.link < 0 and l.peers.count() == 0) break;
fe.sent();
upgrade.locate();
// Asked in the step (the word), done between steps: the
@@ -132,6 +142,8 @@ pub fn Loop(comptime Frontend: type) type {
if (l.core.quit) break;
if (l.core.takeRestore()) |rp| l.restore(rp);
}
+ // The clients' last word: the session ended (Exit).
+ l.peers.ended(0);
// Its serve threads read the core: they end first.
if (l.fs) |f| {
f.deinit(l.gpa);
@@ -148,7 +160,7 @@ pub fn Loop(comptime Frontend: type) type {
/// since the last one died told the shells' masters it held.
pub fn watch(l: *L) void {
if (daemon.relinked()) l.ptys.tellDaemon();
- daemon.watch(l, note);
+ daemon.watch();
}
/// The daemon's thread: an adopted shell onto the queue (taken