diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-02 00:56:05 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-02 00:56:05 -0300 |
| commit | 6637d8df988f8cff9d054c39d3781f4a1ede3b8e (patch) | |
| tree | 113f51d41bbfd75df9352daaf0880b962274eab4 /src/main.zig | |
| parent | c6be02adeb930834aeb7d8c484e89106023550d1 (diff) | |
| download | pardes-6637d8df988f8cff9d054c39d3781f4a1ede3b8e.tar.gz pardes-6637d8df988f8cff9d054c39d3781f4a1ede3b8e.zip | |
pardes --wait with no FILE says it needs one; --detach over a name another session's socket holds (a plain session is named by its pid) says so plainly, and any other failure of it in words, never a Zig error trace
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig index f6a3a3ec..ed70b624 100644 --- a/src/main.zig +++ b/src/main.zig @@ -466,6 +466,10 @@ fn nativeMain(init: std.process.Init) !void { opts.mounts = mounts[0..mounts_len]; if (detach != null and attach != null) badArgs(init.io, "--detach and --attach are opposites: one runs the session, the other joins one", .{}); + // --wait waits on the pane a FILE opens: with none there is nothing to + // wait for (EDITOR=pardes --wait is given the file). + if (wait and positional == null) + badArgs(init.io, "--wait needs a FILE: it returns when that file's pane is closed", .{}); if (opts.ninep_name.len != 0 and attach != null) badArgs(init.io, "--9p names a session's own socket, and --attach has none of its own", .{}); if (opts.ninep_tcp != null and attach != null) @@ -709,7 +713,18 @@ fn nativeMain(init: std.process.Init) !void { name else try std.fmt.allocPrint(arena, "{d}", .{@as(u32, @intCast(std.c.getpid()))}); - return @import("detached/server.zig").run(init, opts, named); + // Said plainly, never a Zig error trace: a name another session's + // socket holds already (a plain session is named by its pid too). + return @import("detached/server.zig").run(init, opts, named) catch |err| { + var words: [128]u8 = undefined; + var said: [512]u8 = undefined; + const why = if (err == error.ListenFailed) + "its socket is taken: another session (a plain one is named by its pid) holds that name; choose another" + else + pardes.Messages.errorWords(err, &words); + std.Io.File.stderr().writeStreamingAll(init.io, std.fmt.bufPrint(&said, "pardes: --detach={s}: {s}\n", .{ named, why }) catch "pardes: --detach failed\n") catch {}; + std.process.exit(1); + }; } if (attach != null and pardes.platform != .tty and pardes.platform != .gui) { try std.Io.File.stderr().writeStreamingAll(init.io, "pardes: --attach needs the tty or gui shell\n"); |
