summaryrefslogtreecommitdiff
path: root/src/exec.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 09:58:15 -0300
committerGabriel Schneider <[email protected]>2026-10-01 10:36:27 -0300
commit70881bb4edd15fe918ee5fed4ed3e8922bc7fc6a (patch)
tree18d80a3172d054cd152f78f56d82150f914b81f2 /src/exec.zig
parentcaa8ed077e8b9b67d18f18b3ec46891bd8d310a7 (diff)
downloadpardes-70881bb4edd15fe918ee5fed4ed3e8922bc7fc6a.tar.gz
pardes-70881bb4edd15fe918ee5fed4ed3e8922bc7fc6a.zip
A command or terminal pane refused for room is refused before anything is logged or answered of it, and a serial is never handed out twice
A command pane with no room logged `new N` and `run N ls`, was answered to its exec, then went with `del N` and no `exit N`; and sync gave N back (`next_serial -= 1`) to the next pane made, so a script holding N found another pane under it. Tty did the same. Both now take a refused placement back at once, before the run is logged or the serial answered (the pane was never announced, so it leaves no record), and fail the write with no room. The decrement is gone: gaps are fine, and a serial once said names one pane for good. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/exec.zig')
-rw-r--r--src/exec.zig23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/exec.zig b/src/exec.zig
index ca48bed1..080d0aea 100644
--- a/src/exec.zig
+++ b/src/exec.zig
@@ -413,9 +413,28 @@ fn spawnTtyWithMount(p: *Pardes, from: usize, v9fs: bool) ?*Pane {
nt.v9fs_on_spawn = v9fs;
nt.body.mode = .tty;
placeNew(p, from, from, free, .shell);
+ if (refusedPlacement(p, free)) {
+ p.reportError(from, "Tty", error.NoPaneRoom);
+ return null;
+ }
return nt;
}
+/// A pane placeNew found no room for: taken back now, before anything is
+/// logged of it or answered with its serial (it was never announced), so
+/// no `new`/`del` pair and no serial a script was told of is left behind.
+fn refusedPlacement(p: *Pardes, id: usize) bool {
+ if (!p.unplaced.isSet(id)) return false;
+ p.unplaced.unset(id);
+ p.removePane(id, null) catch {};
+ // As sync does for a refused pane: none it squeezed stays under its
+ // minimum.
+ for (0..p.ncol) |c| if (!layout.columnAtMinimums(p, c)) {
+ _ = layout.shareColumn(p, c);
+ };
+ return true;
+}
+
/// Whether a shell would be started in `dir` and `dir` is not there: asked
/// only of a host that starts shells, and only of a local path.
pub fn missingDir(p: *Pardes, dir: []const u8) bool {
@@ -811,6 +830,10 @@ fn runCommand(p: *Pardes, from: usize, line: []const u8) ?usize {
pane.command_from = winid(p, src);
echoCommand(p, pane, line);
placeNew(p, from, from, free, .command);
+ if (refusedPlacement(p, free)) {
+ p.reportError(from, "exec", error.NoPaneRoom);
+ return null;
+ }
noteRun(p, pane, "run", line);
return free;
}