diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 06:25:46 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-18 08:01:10 -0300 |
| commit | 8640d280ebc48b0d2658aa13bee2f9ad933c39f3 (patch) | |
| tree | 4336ee5d782fdc2279a0b43a5f5b1c6ccc8074a6 | |
| parent | 96bee017263f60b91f4b4fb2d99771abd07b9465 (diff) | |
| download | pardes-8640d280ebc48b0d2658aa13bee2f9ad933c39f3.tar.gz pardes-8640d280ebc48b0d2658aa13bee2f9ad933c39f3.zip | |
main: pardes-gui --detach runs the pardes beside it in its place: a detached session draws nothing, and a window's binary started SDL, the GPU device and its fonts for it (348.7M instructions before the client could join, 288.8 MB RSS and 60 ms of CPU every 10 s idle); now every detached session is a terminal's (ps says tty) and a window shows it as a client, the ruled direction; with no pardes beside it the window's binary carries on as before. Fresh start, pardes-gui --detach session + window client to its first frame, offscreen: 448/484 ms -> 246/255 ms min/median (own window 241/249: +2.3%), the session's instructions 348.7M -> 18.4M, the client's 376.5M (own 396.5M); the session's RSS 288.8 -> 91.6 MB, idle CPU 59.6 -> 0 ms per 10 s. The manual's How pardes runs says so
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
| -rw-r--r-- | docs/typ/running.typ | 11 | ||||
| -rw-r--r-- | src/main.zig | 17 |
2 files changed, 25 insertions, 3 deletions
diff --git a/docs/typ/running.typ b/docs/typ/running.typ index e78c8f1a..07274157 100644 --- a/docs/typ/running.typ +++ b/docs/typ/running.typ @@ -81,9 +81,14 @@ the same). It draws nothing and is 160×50 until an attach or the root #file("ctl")'s `size` sizes it. Until something attaches, 9P is the only way in (#doc("scripting")). -A terminal's detached session (`pardes --detach`) runs on through its -terminal's hangup while a daemon keeps it. A window's -(`pardes-gui --detach`) ends on it, as any job does. With no daemon, +// main.zig, the --detach branch (the exec of the pardes beside it). +`pardes-gui --detach` runs the `pardes` installed beside it in its place: +a detached session draws nothing, and a window's binary would start a GPU +device and its fonts for it. So every detached session is a terminal's +(`ps` says tty), and a window shows it as a client; only where no `pardes` +is beside it is the session the window's binary, with no window. +A terminal's detached session runs on through its terminal's hangup while +a daemon keeps it; a window's binary's ends on it, as any job does. With no daemon, `--detach` still starts a session, which nothing can attach to: only 9P reaches it. diff --git a/src/main.zig b/src/main.zig index 864e2485..08edc0c1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1501,6 +1501,23 @@ fn nativeMain(std_init: std.process.Init) !void { }; if (attach) |name| if (!resuming) attachTo(init, opts, name); if (detach) |name| { + // A window's binary would start SDL, a GPU device and its fonts for + // a window nobody sees (638M instructions, its socket at 255 ms, + // 1.2% of a CPU idle): the terminal's binary beside it is the + // detached session, as `pardes --detach` (`ps` says tty), its + // windows clients. Without one there, it carries on as a window's. + if (comptime pardes.platform == .gui) if (!resuming) { + var exe: [4096]u8 = undefined; + const n = std.c.readlink("/proc/self/exe", &exe, exe.len); + if (n > 0) if (std.Io.Dir.path.dirname(exe[0..@intCast(n)])) |bin| if (args.len < 64) { + var path_buf: [4104]u8 = undefined; + const path = std.fmt.bufPrintSentinel(&path_buf, "{s}/pardes", .{bin}, 0) catch unreachable; // 4096 + 8 fits + var argv: [64:null]?[*:0]const u8 = @splat(null); + argv[0] = path.ptr; + for (args[1..], 1..) |a, k| argv[k] = a.ptr; + _ = execvp(path.ptr, &argv); + }; + }; // Said plainly, never a Zig error trace: a name a live session's // socket holds already (a plain session is named by its pid too). if (name.len != 0 and !resuming and ninep_io.taken(name)) die(init.io, "a session named {s} is already running", .{name}); |
