diff options
| -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') |
