summaryrefslogtreecommitdiff
path: root/src/9p_io.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-10-01 22:58:12 -0300
committerGabriel Schneider <[email protected]>2026-10-01 22:58:12 -0300
commit3ddd34bcd94ba95d9cacbf6afcb9f89a16a414ce (patch)
treee4fee3fc0c7e228f4ac0a5877eb44b997f7bdb11 /src/9p_io.zig
parent1b654dfeb5b832d110beef0ec7dd8a3b7f66e431 (diff)
downloadpardes-3ddd34bcd94ba95d9cacbf6afcb9f89a16a414ce.tar.gz
pardes-3ddd34bcd94ba95d9cacbf6afcb9f89a16a414ce.zip
Edit's w to a file changed on disk since read is refused once, as Save is (w again to overwrite), the rest of an X/'/w written and the refused named; Edit filters get a pane command's environment ($PARDES_MOUNT, $PARDES_9P, $PARDES_PID, $winid); an Edit with no commands runs beside one whose commands run unless it touches a file that one changes, refused busy (EBUSY) as is a second Edit with commands
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/9p_io.zig')
-rw-r--r--src/9p_io.zig16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/9p_io.zig b/src/9p_io.zig
index a01eb491..18c51ece 100644
--- a/src/9p_io.zig
+++ b/src/9p_io.zig
@@ -1992,6 +1992,16 @@ pub fn start(io: std.Io, gpa: std.mem.Allocator, core: *pardes.Pardes) ?*Listene
/// open to scripts and to mounted shells — while withholding `PARDES_PID`,
/// which is the whole of what `--nested` means.
pub fn exportPaneEnv(listener: ?*const Listener, serial: u32, adopts: bool) void {
+ exportEnv(if (listener) |l| l.path() else null, serial, adopts);
+}
+
+/// exportPaneEnv for a command run off the loop (an Edit's filter), with
+/// this process's own socket: what a pane's command would be given.
+pub fn exportSessionEnv(serial: u32, adopts: bool) void {
+ exportEnv(if (own_socket_len > 0) own_socket[0..own_socket_len] else null, serial, adopts);
+}
+
+fn exportEnv(socket: ?[]const u8, serial: u32, adopts: bool) void {
var announced = false;
if (adopts) announcing: {
var buf: [16]u8 = undefined;
@@ -2001,13 +2011,13 @@ pub fn exportPaneEnv(listener: ?*const Listener, serial: u32, adopts: bool) void
}
if (!announced) _ = unsetenv("PARDES_PID");
- if (listener) |l| exporting: {
+ if (socket) |own| exporting: {
var sock: [sun_path_len]u8 = undefined;
- const path = std.fmt.bufPrintSentinel(&sock, "{s}", .{l.path()}, 0) catch break :exporting;
+ const path = std.fmt.bufPrintSentinel(&sock, "{s}", .{own}, 0) catch break :exporting;
var buf: [16]u8 = undefined;
const id = std.fmt.bufPrintSentinel(&buf, "{d}", .{serial}, 0) catch break :exporting;
if (setenv("PARDES_9P", path, 1) != 0) break :exporting;
- exportMount(l.path());
+ exportMount(own);
if (setenv("PARDES_PANE", id, 1) == 0) return;
}
_ = unsetenv("PARDES_9P");