diff options
| -rw-r--r-- | runtime/main.zig | 8 | ||||
| -rw-r--r-- | test/daemon.py | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/runtime/main.zig b/runtime/main.zig index dc351c30..0751f6b0 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -1176,6 +1176,14 @@ fn nativeMain(std_init: std.process.Init) !void { var positional: ?[:0]const u8 = null; var wait = false; var i: usize = if (resuming or paired != null) 2 else 1; + // An upgraded session's arguments are the ones it was started with: its + // `new` is the verb still, not a file's name (taken for one, the file + // after it was "the second" and the session ended at its Upgrade). + if (resuming and args.len > i and std.meta.stringToEnum(Cmd, args[i]) == .new) { + new_session = true; + new_verb = true; + i += 1; + } // A command's name first: new and attach go on to start or join a // session, with the flags after them; the rest are done in `command`. if (!resuming and args.len > i) if (std.meta.stringToEnum(Cmd, args[i])) |cmd| switch (cmd) { diff --git a/test/daemon.py b/test/daemon.py index c1e0d54a..44221d17 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -767,6 +767,14 @@ def pair_rows(binary): for how in ('HUP', 'TERM'): ended_by(how, *attached('kd')) assert alive(kd) and state_of('kd') == '(tty, kept)', (how, listed()) + # Started by `new` with a file: an Upgrade keeps it (its `new` is the + # verb still: taken for a file's name, the file was "the second" and + # the session ended), and it is attached to after. + upgraded('kd', Client(root / 'pardes-9p-kd.sock'), kd).socket.close() + assert alive(kd) and state_of('kd') == '(tty, kept)', listed() + ended_by('TERM', *attached('kd')) + assert alive(kd) and state_of('kd') == '(tty, kept)', listed() + print('pair rows: `new --detach` with a file: an Upgrade keeps it, and it is attached to after') assert subprocess.run([binary, 'kill', 'kd'], env=env, capture_output=True, timeout=30).returncode == 0 wait_for('kd ended', lambda: not alive(kd), timeout=30) print('pair rows: `new --detach` kept from birth (ps: (tty, kept)); its client ended by HUP, by TERM: it runs on') |
