diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-01 10:38:06 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 10:46:01 -0300 |
| commit | 25844b54fd08dd9cadff2275f2161ee5dd316395 (patch) | |
| tree | adc48e423cae2f4112051e3d40f16e362aa013ca | |
| parent | 860796aa8832bb9bf32b2770bc0584b962bb51b7 (diff) | |
| download | pardes-25844b54fd08dd9cadff2275f2161ee5dd316395.tar.gz pardes-25844b54fd08dd9cadff2275f2161ee5dd316395.zip | |
`pardes --wait` whose $PARDES_9P no longer answers says the session is gone, exit 1, instead of drawing a screen of its own in the asker's terminal
Co-Authored-By: Claude Opus 5.5 <[email protected]>
| -rw-r--r-- | src/main.zig | 12 | ||||
| -rw-r--r-- | test/fs.py | 5 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index 6d895307..f6a3a3ec 100644 --- a/src/main.zig +++ b/src/main.zig @@ -514,7 +514,17 @@ fn nativeMain(init: std.process.Init) !void { // Does it answer? One that answers takes the file or says why not, // as acme's B does: from here on never a nested editor, whose // screen would be drawn inside the pane that asked. - ninep_io.Client.probe(arena, parent.dial) catch break :forwarding; + ninep_io.Client.probe(arena, parent.dial) catch { + // `--wait` is someone's EDITOR waiting on that session: a screen + // of its own drawn in their terminal is no answer. Said, exit 1. + if (wait) { + var buf: [4300]u8 = undefined; + const text = std.fmt.bufPrint(&buf, "pardes: --wait: the session at {s} does not answer; it is gone\n", .{parent.dial[0..@min(parent.dial.len, 4096)]}) catch "pardes: --wait: the session does not answer\n"; + std.Io.File.stderr().writeStreamingAll(init.io, text) catch {}; + std.process.exit(1); + } + break :forwarding; + }; const Refuse = struct { fn with(io: std.Io, what: []const u8, err: anyerror) noreturn { var words_buf: [128]u8 = undefined; @@ -1424,6 +1424,11 @@ def test(binary, quic=False): assert waiting.poll() is None, waiting.stderr.read() client.remove(f'/pane/{far_pane}') assert waiting.wait(timeout=5) == 0 + # --wait with a $PARDES_9P that answers no more: said, exit 1, + # never a screen of its own drawn in the asker's terminal. + dead_env = dict(outside_env, PARDES_9P=str(root / 'pardes-9p-gone.sock')) + gone = subprocess.run([binary, '--wait', str(far)], cwd=root, env=dead_env, capture_output=True, timeout=10) + assert gone.returncode == 1 and b'does not answer' in gone.stderr, gone # `--` ends the options: a name starting with a dash is a name. dash = root / '-dash.txt' dash.write_bytes(b'dash\n') |
