From 63f59cbf3092c8bb7e3eae155969c0249fe2063d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 21 Nov 2026 01:34:10 -0300 Subject: replica: an attach handed to a session as it upgrades is told so and joins the new process, never cut unanswered by the exec: `Peers.refuseAll` returned at once when no client was joined, and with clients its `drop` closed the connections queued in `Peers.inbox` without a word, and a hand-over posted after it was closed by the exec (MSG_CMSG_CLOEXEC), so `pardes attach NAME` started as NAME upgraded said "the session hung up before the dump was whole" and exited 1, with PARDES_PAIR or without (exp2: a `new --detach` session, no variable, ReleaseSafe main: 2 of 20 attaches at 0 ms); now refuseAll tells each queued connection what it tells its clients (`replica.upgrading`, "the session is upgrading to another build of pardes", the words tui and gui passed), `Peers.upgrading` makes `post` tell a later hand-over the same at once (reset at the next boundary: the exec failed), and a first join told so dials again patiently (`join` -> `redial`, its view optional); the pair row that failed on the release build only (daemon.py --pair, `ended_by(how, *attached('rows'))`, the coordinator's landing check) was this race, reached through the test: its `upgraded()` waited for `--upgraded=` in the session's command line, which a second Upgrade's old process already had, so it attached to the old process; found under strace (the daemon handed the attach, then took the session's `upgrade`, then exec'd); the release build and the test's long runtime path only moved the timing; `upgraded()` now waits for the session's 9P socket made anew; tests: core/replica.zig "an Upgrade tells a client handed to the session and not joined yet that it is upgrading ..." (main: both hand-overs still queued, never told), test/daemon.py `attach_upgrading` (plain, --pair, --attach-upgrading: an attach started 0-25 ms after the Upgrade's word, without the variable and with it: main's release build failed its first round) Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/gui/gui.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dev/gui/gui.zig') diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 521f685f..d10173b4 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -2501,7 +2501,7 @@ const Shell = struct { core.settle(); // Its replica clients told, their views gone before the dump: each // dials the session again once it is back. - s.peers.refuseAll(core, "the session is upgrading to another build of pardes"); + s.peers.refuseAll(core); var rec: upgrade.Record = .{ .link = daemon.link, .window = s.gui != null, .exe = path }; s.ptys.record(&rec); var at_buf: [1024:0]u8 = undefined; -- cgit v1.3 From fe0aa07c18a9fd5ca6bdcb78e9354a2745e32298 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sat, 21 Nov 2026 03:29:45 -0300 Subject: client: what the pair's last rounds left, each a test first: a window client exec'd at its session's Upgrade comes back the size it was, not the default (runtime/client.zig `execAgain` passed `--attach=` alone, so the new process made a 1120x720 window: a `--geometry=900x560` pair's session went from 56x16 to 70x20 after an Upgrade to another build, with the variable or without (any `pardes-gui attach`); now the window's size at the exec, SDL_GetWindowSize, as `--geometry=WxH`); a pair's client exec'd at an Upgrade waits for its session at `ended` as before the exec (tui.zig and gui.zig `runClient` asked `opts.pair`, which the exec'd `--attach=` client has not: now every near client waits, a non-child answers ECHILD at once; not seen to fail here: the subreaper took the session first); tests in test/daemon.py: `pair_upgrade_views` (plain, --pair: two clients' own views, the pair's scroll and the attach's focus, the same after a same-build Upgrade: the screens by pyte, the focus by where typing lands: passed before this change too), `pair_exec_reaps`, `far_exec` (a far client, PARDES_REPLICA_FAR by the socket's path, execs the build at its start path and agrees after: passed before too), `pair_window_geometry` (offscreen, not test mode: failed before), the last three in --upgrade OLD NEW Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- dev/gui/gui.zig | 14 ++- dev/tui/tui.zig | 10 +- runtime/client.zig | 7 +- test/daemon.py | 324 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 341 insertions(+), 14 deletions(-) (limited to 'dev/gui/gui.zig') diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index d10173b4..d779cf47 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -1429,16 +1429,22 @@ fn clientSession(init: std.process.Init, g: *Gui, opts_in: pardes.Options, test_ .gone => Said.no(io, "'{s}' let this client go (a Detach in it, or the session's end)", .{to.session}), .failed => Said.no(io, "{s}", .{start.said()}), // A new process's window: the build at its start path, exec'd. - .upgrade => |view| Said.no(io, "{s}", .{client_loop.execAgain(&start, view)}), + .upgrade => |view| { + // Its new window the size this one has now. + var size: [2]c_int = .{ 0, 0 }; + _ = c.SDL_GetWindowSize(g.window, &size[0], &size[1]); + Said.no(io, "{s}", .{client_loop.execAgain(&start, view, size)}); + }, .left => { var said: [600]u8 = undefined; std.Io.File.stderr().writeStreamingAll(io, std.fmt.bufPrint(&said, "pardes-gui: detached from '{s}', which is still running; come back with `pardes-gui attach {s}`\n", .{ to.session, to.session }) catch "pardes-gui: detached\n") catch {}; std.process.exit(0); }, .ended => |code| { - // A pair's window is its session's parent: its status once it - // is gone, as the terminal's (tui.zig `runClient`). - if (opts_in.pair != null) { + // A pair's window is its session's parent, an exec'd one too: + // its status once it is gone, as the terminal's (tui.zig + // `runClient`). + if (!to.far) { var status: c_int = 0; while (libc.waitpid(@intCast(start.joined.pid), &status, 0) < 0 and libc.errno(-1) == .INTR) {} } diff --git a/dev/tui/tui.zig b/dev/tui/tui.zig index a6d2216d..09704424 100644 --- a/dev/tui/tui.zig +++ b/dev/tui/tui.zig @@ -800,9 +800,11 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8, }, .ended => |code| { screen.leave(); - // A pair's client is its session's parent: its status once it - // is gone, as a terminal's job ends with its program. - if (opts.pair != null) { + // A pair's client is its session's parent, an exec'd one too + // (an Upgrade's, which `opts.pair` no longer says): its status + // once it is gone, as a terminal's job ends with its program. + // Not its child: no wait (ECHILD at once). + if (!far_link) { var status: c_int = 0; while (libc.waitpid(@intCast(start.joined.pid), &status, 0) < 0 and libc.errno(-1) == .INTR) {} } @@ -816,7 +818,7 @@ pub fn runClient(init: std.process.Init, opts: pardes.Options, path: []const u8, // The blink: its screen left, the build at its start path // exec'd, which enters it again. screen.leave(); - Said.no(io, "{s}", .{client_loop.execAgain(&start, view)}); + Said.no(io, "{s}", .{client_loop.execAgain(&start, view, null)}); }, } } diff --git a/runtime/client.zig b/runtime/client.zig index c550b0fa..22e60fc1 100644 --- a/runtime/client.zig +++ b/runtime/client.zig @@ -125,11 +125,14 @@ pub const Ended = union(enum) { done, gone, failed, left, ended: u8, upgrade: u8 /// process's child still), joining for `view` (PARDES_JOIN_VIEW; far, /// PARDES_REPLICA_FAR). The terminal's blink: no record crosses the exec. /// Returns only when the exec failed: why. -pub fn execAgain(s: *Start, view: u8) []const u8 { +pub fn execAgain(s: *Start, view: u8, size: ?[2]c_int) []const u8 { const path = upgrade.exe() orelse return "Upgrade: this client does not know the path it was started from"; var at_buf: [4200]u8 = undefined; const at = std.fmt.bufPrintSentinel(&at_buf, "--attach={s}:{s}", .{ s.dial.path, s.dial.session }, 0) catch return "Upgrade: the session's socket's path is too long to attach again by"; - const argv = [_:null]?[*:0]const u8{ path, at }; + // A window's new window the size it had (`--geometry`), not the default. + var size_buf: [48]u8 = undefined; + const geometry: ?[*:0]const u8 = if (size) |wh| (std.fmt.bufPrintSentinel(&size_buf, "--geometry={d}x{d}", .{ wh[0], wh[1] }, 0) catch unreachable).ptr else null; // two c_ints fit 48 + const argv = [_:null]?[*:0]const u8{ path, at, geometry }; var view_buf: [32]u8 = undefined; const joining = std.fmt.bufPrintSentinel(&view_buf, "PARDES_JOIN_VIEW={d}", .{view}, 0) catch unreachable; // a u8 fits 32 var n: usize = 0; diff --git a/test/daemon.py b/test/daemon.py index 5744b099..7a600048 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -30,7 +30,8 @@ private HOME and runtime directory: python3 -B test/daemon.py --pair PARDES_PAIR: a terminal's session and its first client python3 -B test/daemon.py --attach-upgrading - an attach started as its session upgrades (in plain and --pair too) + an attach started as its session upgrades, and two clients' views + across an Upgrade (in plain and --pair too) python3 -B test/daemon.py --relink the daemon killed: its sessions register again with the next; and one stopped: an Adopt waits for its answer to the hello @@ -44,6 +45,7 @@ private HOME and runtime directory: at 0/30/80/207 ms, and a window's session serving replicas """ import fcntl +import json import os import random import re @@ -925,6 +927,312 @@ def attach_upgrading(binary, rounds=6): shutil.rmtree(root, ignore_errors=True) +def pair_upgrade_views(binary): + """PARDES_PAIR, two clients each in its own view (the pair's own terminal + and an attach), each with its own scroll and focus: the pair's scrolled + down a long file a page at a time, the attach's focus on a pane of its + own (New); an Upgrade lets both go and each joins again for its view + (views.away): the same lines shown, the cursor where it was, in each.""" + import pyte + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rv-', dir=scratch)) + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(300))) + terms = [] + + def screen(t): + s = pyte.Screen(100, 30) + # Its colours (SGR with colons, which pyte misreads) left out. + pyte.ByteStream(s).feed(re.sub(rb'\x1b\[[0-9:;]*m', b'', t.text())) + return s + + def shown(t): + """The notes' lines it shows, and its cursor.""" + s = screen(t) + return sorted(int(m.group(1)) for row in s.display for m in re.finditer(r'line (\d+) of the notes', row)), (s.cursor.x, s.cursor.y) + + def settled(t): + last = [None, 0] + + def same(): + now = shown(t) + if now != last[0]: + last[0], last[1] = now, time.monotonic() + return time.monotonic() - last[1] > 1.5 and now + return wait_for('its screen settled', same, timeout=30) + + try: + t = Term(30, 100) + terms.append(t) + c = t.spawn([binary, '--9p=pv', str(notes)], env) + sock = root / 'pardes-9p-pv.sock' + wait_for('the socket', sock.exists) + nine = Client(sock) + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) + for _ in range(3): + os.write(t.master, b'\x1b[6~') + time.sleep(.2) + tt = Term(30, 100) + terms.append(tt) + a = tt.spawn([binary, 'attach', 'pv'], env) + wait_for('the attach drawn', lambda: b'\x1b[?1049h' in tt.text(), timeout=30) + os.write(tt.master, b'j') + time.sleep(.3) + before_panes = view_panes(nine) + nine.write('/exec', b'New\n') + wait_for('a pane in the attach\'s view', lambda: view_panes(nine) - before_panes) + + def focus(): + """Each client's focus: its view live (a key that moves nothing).""" + got = [] + for term in (t, tt): + os.write(term.master, b'\x1b') + time.sleep(.6) + got.append(nine.read('/focus')) + return got + focused = focus() + before = settled(t), settled(tt) + assert before[0][0] and before[0][0][0] >= 40, ('the pair scrolled', before[0]) + marks = len(t.text()), len(tt.text()) + ino = sock.stat().st_ino + nine.write('/ctl', b'Upgrade\n') + nine.socket.close() + wait_for('the session exec\'d', lambda: sock.stat().st_ino != ino, timeout=60) + nine = reconnect(sock) + for term, mark in zip((t, tt), marks): + wait_for('joined again', lambda: b'joined again' in term.text()[mark:], timeout=30) + after = settled(t), settled(tt) + assert after == before, ('each client\'s lines and cursor as they were', before, after) + # Its focus: what it types lands in the pane it had the keyboard in + # (/focus, read after a key, is which view is live then: not a + # client's own). + for term, pane, word in zip((t, tt), focused, (b'PAIRTYPED', b'ATTACHTYPED')): + os.write(term.master, b'i' + word + b'\x1b') + wait_for('typed into its pane', lambda: word in nine.read(f'/pane/{int(pane)}/body'), timeout=10) + print('pair upgrade views: two clients, each its own view: the pair\'s scroll and the attach\'s focus as they were after an Upgrade') + nine.socket.close() + a.terminate() + a.wait(timeout=20) + os.kill(c.pid, signal.SIGTERM) + c.wait(timeout=20) + wait_for('the session ended', lambda: not alive(session), timeout=30) + finally: + for p in processes(root): + try: + os.kill(p, signal.SIGKILL) + except OSError: + pass + for t in terms: + t.close() + shutil.rmtree(root, ignore_errors=True) + + +def pair_exec_reaps(old, new): + """PARDES_PAIR across builds: a pair started from `root/bin` (old), its + session upgraded to the build installed there since (new): its client, + the session's parent, execs that build (the blink) and is still its + parent; Exit typed then: the client returns once the session is gone, + reaped, its status the session's (0), as before the exec.""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rpx-', dir=scratch)) + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1', PARDES_PAIR='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + (root / 'bin').mkdir() + binary = root / 'bin' / 'pardes' + install(old, binary) + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) + terms = [] + try: + t = Term(30, 100) + terms.append(t) + c = t.spawn([str(binary), '--9p=px', str(notes)], env) + sock = root / 'pardes-9p-px.sock' + wait_for('the socket', sock.exists) + nine = Client(sock) + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + assert ppid(session) == c.pid + wait_for('drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) + install(new, binary) + ino = sock.stat().st_ino + nine.write('/ctl', b'Upgrade\n') + nine.socket.close() + wait_for('the session exec\'d', lambda: sock.stat().st_ino != ino, timeout=60) + wait_for('the client on the new build', lambda: exe_of(c.pid) == (str(binary), True), timeout=30) + nine = reconnect(sock) + assert ppid(session) == c.pid + mark = len(t.text()) + wait_for('drawn again', lambda: b'line 3 of the notes' in t.text()[mark:], timeout=30) + nine.write('/ctl', b'Exit\n') + nine.socket.close() + assert c.wait(timeout=30) == 0, c.returncode + # Its parent's wait returned: the session reaped, not a zombie left + # to whoever takes it in. + assert not os.path.exists(f'/proc/{session}') if procfs else not alive(session), open(f'/proc/{session}/stat').read() + print('pair exec reaps: a pair\'s client exec\'d at its session\'s Upgrade still reaps it at Exit, status 0') + finally: + for p in processes(root): + try: + os.kill(p, signal.SIGKILL) + except OSError: + pass + for t in terms: + t.close() + shutil.rmtree(root, ignore_errors=True) + + +def far_exec(old, new): + """A far client (PARDES_REPLICA_FAR, as through ssh's forward) of a + session started from `root/bin` (old), the session upgraded to the build + installed there since (new): the far client execs the build at its own + start path (its install holds the session's build now), the same + process, far still, and is back in its view: its key steps the session + and its digest agrees. Not through ssh: its forward's own end is not + here (its socket file left behind at the exec, the far install holding + another build: not covered).""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rfx-', dir=scratch)) + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + TERM='xterm-256color', SHELL=shutil.which('bash') or '/bin/bash', PARDES_NOTIME='1') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + (root / 'bin').mkdir() + binary = root / 'bin' / 'pardes' + install(old, binary) + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) + terms = [] + try: + out = subprocess.run([str(binary), 'new', '--detach=fx', str(notes)], env=env, cwd=root, capture_output=True, timeout=30) + assert out.returncode == 0, out + sock = root / 'pardes-9p-fx.sock' + nine = Client(sock) + session = int(dict(line.split(maxsplit=1) for line in nine.read('/status').decode().splitlines())['pid']) + t = Term(30, 100) + terms.append(t) + check = root / 'f.check' + c = t.spawn([str(binary), f'--attach={root / "pardes-replica.sock"}:fx'], + dict(env, PARDES_REPLICA_FAR='1', PARDES_REPLICA_CHECK=str(check))) + wait_for('the far client drawn', lambda: b'line 3 of the notes' in t.text(), timeout=30) + key = lambda b: os.write(t.master, b) # noqa: E731 + seen = len(checks(check)) + key(b'gg') + wait_for('its key stepped', lambda: agreed(check, seen + 1), timeout=30) + install(new, binary) + mark = len(t.text()) + ino = sock.stat().st_ino + nine.write('/ctl', b'Upgrade\n') + nine.socket.close() + wait_for('the session exec\'d', lambda: sock.stat().st_ino != ino, timeout=60) + nine = reconnect(sock) + wait_for('the far client on the new build', lambda: exe_of(c.pid) == (str(binary), True), timeout=30) + assert b'PARDES_REPLICA_FAR=1' in open(f'/proc/{c.pid}/environ', 'rb').read().split(b'\0') if procfs else True + wait_for('the terminal entered again', lambda: t.text().rfind(b'\x1b[?1049h') > t.text().rfind(b'\x1b[?1049l') > mark, timeout=30) + seen = len(checks(check)) + key(b'j') + wait_for('its key stepped after', lambda: agreed(check, seen + 1), timeout=30) + assert c.poll() is None + print('far exec: a far client exec\'d the build at its start path at its session\'s Upgrade, far still, and agrees') + c.terminate() + c.wait(timeout=20) + nine.socket.close() + assert subprocess.run([str(binary), 'kill', 'fx'], env=env, capture_output=True, timeout=30).returncode == 0 + wait_for('the session ended', lambda: not alive(session), timeout=30) + finally: + for p in processes(root): + try: + os.kill(p, signal.SIGKILL) + except OSError: + pass + for t in terms: + t.close() + shutil.rmtree(root, ignore_errors=True) + + +def pair_window_geometry(gui_binary, new_gui): + """PARDES_PAIR, a window with `--geometry=WxH` (offscreen, not test + mode: its grid is its window's): another build at its start path, its + session upgraded: the window client execs it, and its new window is the + size it had (the session's grid as before), not the default's.""" + scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn' + scratch.mkdir(parents=True, exist_ok=True) + root = Path(tempfile.mkdtemp(prefix='rgg-', dir=scratch)) + env = {k: v for k, v in os.environ.items() if not k.startswith('PARDES_') and 'PAGER' not in k} + env.update(HOME=str(root), XDG_RUNTIME_DIR=str(root), XDG_CONFIG_HOME=str(root / 'config'), + SHELL='/bin/bash', PARDES_NOTIME='1', PARDES_DAEMON='on', TERM='xterm-256color', PARDES_PAIR='1', + SDL_VIDEO_DRIVER='offscreen') + (root / 'config' / 'pardes').mkdir(parents=True) + (root / 'config' / 'pardes' / 'init').write_text('Shell bash\nMessageLinger 0\n') + notes = root / 'notes.txt' + notes.write_text(''.join(f'line {i} of the notes\n' for i in range(30))) + (root / 'bin').mkdir() + gui = root / 'bin' / 'pardes-gui' + install(Path(gui_binary), gui) + install(Path(gui_binary).with_name('pardes'), gui.with_name('pardes')) + procs = [] + + def grid(nine): + s = json.loads(nine.read('/screen')) + return s['cols'], s['rows'] + + def started(name, *flags): + p = subprocess.Popen([str(gui), f'--9p={name}', *flags, str(notes)], env=env, cwd=root, stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, stderr=open(root / f'{name}.err', 'w'), start_new_session=True) + procs.append(p) + sock = root / f'pardes-9p-{name}.sock' + wait_for(f'session {name}\'s 9P socket', sock.exists, timeout=30) + nine = Client(sock) + wait_for('its window\'s grid', lambda: grid(nine) != (80, 24), timeout=30) + time.sleep(1) + return p, nine, grid(nine) + + try: + p0, n0, plain = started('plain') + n0.write('/ctl', b'Exit\n') + n0.socket.close() + p0.wait(timeout=30) + p, nine, sized = started('sized', '--geometry=900x560') + assert sized != plain, ('--geometry makes its own grid', sized, plain) + install(Path(new_gui), gui) + install(Path(new_gui).with_name('pardes'), gui.with_name('pardes')) + sock = root / 'pardes-9p-sized.sock' + ino = sock.stat().st_ino + nine.write('/ctl', b'Upgrade\n') + nine.socket.close() + wait_for('the session exec\'d', lambda: sock.stat().st_ino != ino, timeout=60) + wait_for('the window on the new build', lambda: exe_of(p.pid) == (str(gui), True), timeout=30) + nine = reconnect(sock) + time.sleep(3) + assert grid(nine) == sized, ('the exec\'d window the size it had', grid(nine), sized, plain) + print(f'pair window geometry: --geometry=900x560 ({sized[0]}x{sized[1]}, the default {plain[0]}x{plain[1]}): the window exec\'d at an Upgrade the size it had') + nine.write('/ctl', b'Exit\n') + nine.socket.close() + p.wait(timeout=30) + finally: + for p in procs: + if p.poll() is None: + p.kill() + for q in processes(root): + try: + os.kill(q, signal.SIGKILL) + except OSError: + pass + shutil.rmtree(root, ignore_errors=True) + + def manage(binary): """`pardes --ps`, `--kill=NAME` and `--kill-all`: two detached sessions and their shells listed, one session killed outright and its shell @@ -2132,6 +2440,7 @@ def main(binary, cycles): pair(binary) pair_rows(binary) attach_upgrading(binary) + pair_upgrade_views(binary) manage(binary) relink(binary) answer_late(binary) @@ -3070,10 +3379,16 @@ if __name__ == '__main__': if sys.argv[1:3] == ['--upgrade', '--gui']: gui_upgrades(Path(sys.argv[3]).resolve(), Path(sys.argv[4]).resolve()) elif sys.argv[1:2] == ['--upgrade']: - upgrades(Path(sys.argv[2]).resolve(), Path(sys.argv[3]).resolve()) + old, new = Path(sys.argv[2]).resolve(), Path(sys.argv[3]).resolve() + upgrades(old, new) + if knows_exec(old): + pair_exec_reaps(old, new) + far_exec(old, new) # With a pardes-gui beside each: the clients carried too. - if all(Path(a).resolve().with_name('pardes-gui').exists() for a in sys.argv[2:4]): - upgrade_clients(Path(sys.argv[2]).resolve(), Path(sys.argv[3]).resolve()) + if all(a.with_name('pardes-gui').exists() for a in (old, new)): + upgrade_clients(old, new) + if knows_exec(old): + pair_window_geometry(old.with_name('pardes-gui'), new.with_name('pardes-gui')) elif sys.argv[1:2] == ['--upgrade-clients']: upgrade_clients(Path(sys.argv[2]).resolve(), Path(sys.argv[3]).resolve()) elif sys.argv[1:2] == ['--clients']: @@ -3086,6 +3401,7 @@ if __name__ == '__main__': pair(sys.argv[2]) pair_rows(sys.argv[2]) attach_upgrading(sys.argv[2]) + pair_upgrade_views(sys.argv[2]) elif sys.argv[1:2] == ['--attach-upgrading']: attach_upgrading(sys.argv[2]) elif sys.argv[1:2] == ['--relink']: -- cgit v1.3