summaryrefslogtreecommitdiff
path: root/src/ninep/pty.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/pty.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/pty.zig')
-rw-r--r--src/ninep/pty.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ninep/pty.zig b/src/ninep/pty.zig
index 68f98554..aa0f499a 100644
--- a/src/ninep/pty.zig
+++ b/src/ninep/pty.zig
@@ -61,6 +61,12 @@ pub fn writeCtl(p: *Pardes, req: Req, id: usize) Reply {
while (it.next()) |raw| {
const line = std.mem.trim(u8, raw, " \t\r");
if (line.len == 0) continue;
+ // A shell restarted where the directory is gone would not start:
+ // refused before anything runs, as Tty there is.
+ if (!apply and std.mem.eql(u8, line, "exec")) if (p.panes[id]) |pane| if (pardes.exec.missingDir(p, pane.cwdSlice())) {
+ const dir = pane.cwdSlice();
+ return tree.failText(req.tag, E.NOENT, std.fmt.bufPrint(&p.fs.ename, "exec: {s}: no such directory", .{dir[0..@min(dir.len, 256)]}) catch "exec: no such directory");
+ };
if (!verb(p, id, line, apply)) return tree.failText(req.tag, E.INVAL, if (outOfRange(line)) e_winsize_range else e_bad_pty_ctl);
}
}