diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 04:00:33 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 04:03:06 -0300 |
| commit | 9ac223e5436a9f5831c97382270dedbf9f13277d (patch) | |
| tree | 7d2bf31977f98cc81e7e9133e674d0f6e7bdfed5 | |
| parent | 8dc84e6f9f1c3802f1d28de4d49907381cdf224b (diff) | |
| download | pardes-9ac223e5436a9f5831c97382270dedbf9f13277d.tar.gz pardes-9ac223e5436a9f5831c97382270dedbf9f13277d.zip | |
--wait waits on the pane its look answered, read on the look's own open, not one found again by name in /index
The forwarded look was a write and nothing more, and --wait then
looked its file up in /index. /index shows names escaped (`\\` for a
backslash, `\xNN`), so a file named with one matched no pane and
--wait exited 0 at once, as if the pane were already closed. The look
is now asked on one open (Client.ask) and its answer is the pane
waited on; /index by name stays only for a look that answers none.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | src/main.zig | 17 | ||||
| -rw-r--r-- | test/fs.py | 16 |
2 files changed, 27 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); @@ -1395,6 +1395,22 @@ def test(binary, quic=False): assert time.monotonic() - deleted < .05, time.monotonic() - deleted assert second.wait(timeout=5) == 0 assert edited.read_bytes() == b'edited\n' + # --wait waits on the pane its look answered, on the look's own + # open: a name /index shows escaped (a backslash is `\\` there) + # is still the pane waited on, not one already gone. + odd = root / 'wait\\odd.txt' + odd.write_bytes(b'odd\n') + before = serials() + waiting = subprocess.Popen([binary, '--wait', str(odd)], cwd=root, env=env, + stdout=subprocess.DEVNULL, stderr=subprocess.PIPE) + deadline = time.monotonic() + 3 + while not serials() - before and time.monotonic() < deadline: + time.sleep(.01) + odd_pane, = serials() - before + time.sleep(.5) + assert waiting.poll() is None, waiting.stderr.read() + client.remove(f'/pane/{odd_pane}') + assert waiting.wait(timeout=5) == 0 # A name not there yet opens a pane named it, as acme's B does, # and Save creates it: git's and fish's temporary files are. fresh = root / 'wait new.txt' |
