summaryrefslogtreecommitdiff
path: root/src/ninep/ctl.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-29 09:09:47 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:16 -0300
commit4d4818f7baf356866d323e4b337a64a3dddd8adb (patch)
tree3128484fd60a000c5e0fe207b4e34e658d3bdad6 /src/ninep/ctl.zig
parent44aa1ff5bf19b4020e9b4600e5286dea35a3ba5c (diff)
downloadpardes-4d4818f7baf356866d323e4b337a64a3dddd8adb.tar.gz
pardes-4d4818f7baf356866d323e4b337a64a3dddd8adb.zip
pty/ctl exec fails the write when the shell cannot start; a directory removed under a shell leaves its name
`exec` on pty/ctl restarted a shell in a directory that was gone, the write succeeding and the pane dead; and the pane was then renamed `<dir> (deleted)` from /proc, so a restart failed even once the directory was back. `exec` is now refused up front, ENOENT, where the directory is gone; a shell the host cannot start fails the waiting write (late failure, as a Save's); and a `(deleted)` cwd is no name to take. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/ninep/ctl.zig')
-rw-r--r--src/ninep/ctl.zig19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig
index eea033ed..2f94dd3c 100644
--- a/src/ninep/ctl.zig
+++ b/src/ninep/ctl.zig
@@ -1949,6 +1949,25 @@ test "a command line from a missing directory fails ENOENT and makes no pane; a
try testing.expect(th.logHas(p, "shell: directory missing"));
}
+test "pty/ctl exec in a directory that is gone fails ENOENT; a shell that cannot start fails the write" {
+ const p = try th.withTerm(testing.allocator);
+ defer p.deinit();
+ const Starting = struct {
+ fn spawn(_: ?*anyopaque, _: u8, _: []const u8) void {}
+ };
+ p.host = .{ .vtable = &.{ .spawn = Starting.spawn } };
+ defer p.host = .{};
+ const serial = serialOf(p);
+ p.setCwd(p.paneBySerial(serial).?, "/tmp/pardes-no-such-dir-zz");
+ const refused = wr(p, Node.of(serial, .pty_ctl), "exec\n");
+ try testing.expectEqual(E.NOENT, refused.errno());
+ try testing.expectStringStartsWith(refused.reply.ename, "exec: /tmp/pardes-no-such-dir-zz: no such directory");
+ // The host's own failure is the waiting write's (late_failure).
+ p.fs.late_failure_len = 0;
+ p.shellFailed(@intCast(p.paneBySerial(serial).?), error.AccessDenied);
+ try testing.expectEqualStrings("shell: access denied", p.fs.late_failure[0..p.fs.late_failure_len]);
+}
+
test "size is monotonic: growing is never refused, and a size once taken is taken again" {
const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 60 });
defer p.deinit();