diff options
Diffstat (limited to 'runtime/main.zig')
| -rw-r--r-- | runtime/main.zig | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/runtime/main.zig b/runtime/main.zig index a791ffec..24ed1456 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -323,8 +323,10 @@ const cmds = std.EnumArray(Cmd, Doc).init(.{ .doc = \\Start a session here, even in a pane of another: in this terminal for \\pardes, a window for pardes-gui, or with --detach none until one - \\attaches. Bare `pardes` takes the same flags, and starts one unless - \\it is in a pane (where it hands its FILE to that session). + \\attaches, which returns once the session runs and prints its name. + \\Bare `pardes` takes the same flags, and starts one unless it is in a + \\pane (where it hands its FILE to that session); its --detach is the + \\session itself, until it ends (a supervisor's way). , .examples = &.{ .{ "pardes new", "a session here, its shell pane in tty mode" }, @@ -1157,6 +1159,8 @@ fn nativeMain(std_init: std.process.Init) !void { const resuming = upgrade.resumed != null; var session_only = true; var new_session = false; + // `pardes new`: with --detach it returns once the session runs. + var new_verb = false; var explicit_tty = false; var detach: ?[]const u8 = null; var attach: ?[]const u8 = null; @@ -1168,6 +1172,7 @@ fn nativeMain(std_init: std.process.Init) !void { if (!resuming and args.len > 1) if (std.meta.stringToEnum(Cmd, args[1])) |cmd| switch (cmd) { .new => { new_session = true; + new_verb = true; i = 2; }, .attach => { @@ -1537,6 +1542,9 @@ fn nativeMain(std_init: std.process.Init) !void { // 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}); if (opts.ninep_name.len == 0) opts.ninep_name = name; + // `new --detach` forks the session and returns once it runs; the + // flag alone is the session itself (a supervisor's, a harness's). + if (new_verb and !resuming) daemon.launch(opts.ninep_name); // Said where it was started (stderr, as the log says it): no pane // anyone sees would show it. The session runs on, with no 9P. var pid_buf: [16]u8 = undefined; |
