From 1ab1d412e2768d9fe56a9e97ab60716a6d31063a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 23:00:16 -0300 Subject: A second pardes --detach=NAME while NAME runs says "a session named NAME is already running" and exits 1, with no error trace The second session built its whole core before its bind failed, then returned an error that main printed with a Zig error-return trace. The name is now checked first: a live session's socket is said, and the process exits 1 having made nothing. Co-Authored-By: Claude Opus 5.5 --- src/detached/server.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/detached/server.zig b/src/detached/server.zig index 78b85836..588912bb 100644 --- a/src/detached/server.zig +++ b/src/detached/server.zig @@ -1238,6 +1238,17 @@ pub const detached_cols = 160; pub const detached_rows = 50; pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void { + // A name a live session holds: said, exit 1, before anything is made + // (no error trace, no second session racing the first for the socket). + if (comptime supported) { + var path_buf: [path_max]u8 = undefined; + if (sessionPath(&path_buf, name)) |path| if (ninep_io.statNoFollow(path) != null and alive(path)) { + var said: [path_max + 64]u8 = undefined; + const text = std.fmt.bufPrint(&said, "pardes: a session named {s} is already running\n", .{name}) catch "pardes: a session of that name is already running\n"; + std.Io.File.stderr().writeStreamingAll(init.io, text) catch {}; + std.process.exit(1); + }; + } const gpa = init.gpa; const allocs = pardes.memory.init(gpa); defer pardes.memory.deinit(); @@ -1282,7 +1293,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options, name: []const u8) !void try session.initAsync(); if (!session.listen(name)) { try std.Io.File.stderr().writeStreamingAll(init.io, "pardes: could not bind a detached session socket\n"); - return error.NoSocket; + std.process.exit(1); } session.ninep = ninep_io.listen(init.io, gpa, core, opts.ninep_name, name, opts.ninep_tcp, opts.ninep_quic); -- cgit v1.3