summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.zig17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/main.zig b/src/main.zig
index 6c46b22c..de501047 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -281,11 +281,12 @@ fn forwardWords(err: anyerror, buf: []u8) []const u8 {
/// connection ends with the session -- exit 1.
fn waitForDel(io: std.Io, gpa: std.mem.Allocator, dial: []const u8, path: []const u8, known: ?u32) noreturn {
_ = io;
- // The pane this launch made (a name not there yet) is known by its
- // serial; one a look opened or went to is found by its file. Found by
- // none after the look went there, it was closed already: that is the
- // end being waited for, not a failure (a pane closed between the look
- // and this read made `--wait` exit 1 before).
+ // The pane this launch made (a name not there yet), or the one its
+ // look answered, is known by its serial; one the look answered none
+ // for is found by its file. Found by none after the look went there,
+ // it was closed already: that is the end being waited for, not a
+ // failure (a pane closed between the look and this read made `--wait`
+ // exit 1 before).
const serial = known orelse found: {
const first = ninep_io.Client.read(gpa, dial, "/index", "/index") catch std.process.exit(1);
defer gpa.free(first);
@@ -660,7 +661,11 @@ fn nativeMain(init: std.process.Init) !void {
if (found_path != null) {
var command_buf: [8192]u8 = undefined;
const command = std.fmt.bufPrint(&command_buf, "{s}{s}\n", .{ path, word[target.path.len..] }) catch |err| Refuse.with(init.io, word, err);
- ninep_io.Client.write(arena, parent.dial, look, command) catch |err| Refuse.with(init.io, word, err);
+ // The pane it went to, read on the open that asked (another
+ // client's look meanwhile is not this one's): what --wait waits on.
+ const went = ninep_io.Client.ask(arena, parent.dial, look, command) catch |err| Refuse.with(init.io, word, err);
+ var rows = std.mem.tokenizeAny(u8, went, " \n");
+ if (rows.next()) |row| made_serial = std.fmt.parseInt(u32, row, 10) catch null;
} else {
const made = ninep_io.Client.read(arena, parent.dial, "/pane/new", "/pane/new") catch |err| Refuse.with(init.io, word, err);
const serial = std.fmt.parseInt(u32, std.mem.trim(u8, made, " \n"), 10) catch |err| Refuse.with(init.io, word, err);