diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 1539637c..5ba95be3 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -1468,6 +1468,22 @@ test "a command pane shows how its command ended, and the next command there run var want: [64]u8 = undefined; try std.testing.expect(std.mem.indexOf(u8, log.bytes, try std.fmt.bufPrint(&want, "run {d} make\n", .{pane.serial})) != null); try std.testing.expect(std.mem.indexOf(u8, log.bytes, try std.fmt.bufPrint(&want, "exit {d} 2\n", .{pane.serial})) != null); + // A signal for a pane is not performed on whoever takes its slot. + const Count = struct { + var signals: usize = 0; + const vtable: Host.VTable = .{ .pty_signal = signal }; + fn signal(_: ?*anyopaque, _: u8, _: PtySignal) void { + signals += 1; + } + }; + const host_before = p.host; + p.host = .{ .vtable = &Count.vtable }; + try std.testing.expect(p.executeBuiltinLine(0, "Kill make")); + try p.removePane(dst, null); + _ = try p.newCommand(dst, "", "other"); + while (p.nextEffect()) |effect| if (effect == .signal_pty) p.perform(effect); + try std.testing.expectEqual(@as(usize, 0), Count.signals); + p.host = host_before; // A command line longer than a command pane takes is refused. const long = "x" ** (exec.command_max + 1); try std.testing.expectEqual(@as(?usize, null), exec.execute(p, 1, long)); @@ -3187,7 +3203,8 @@ pub const Effect = union(enum) { spawn: struct { pane: u8, serial: u32, cwd: Buf(effect_path_cap) }, write: struct { pane: u8, bytes: Buf(64) }, resize_pty: struct { pane: u8, cols: u16, rows: u16 }, - signal_pty: struct { pane: u8, sig: PtySignal }, + /// For the pane whose serial is `serial`, as `spawn` is (perform). + signal_pty: struct { pane: u8, serial: u32, sig: PtySignal }, /// The terminal pane in this slot is gone: the shell hangs up its pty /// and ends the shell, rather than leave it running with nobody to read. close_pty: struct { pane: u8 }, @@ -4665,7 +4682,9 @@ pub const Pardes = struct { // screen, and the bytes are dropped rather than transcribed. .write => |w| if (v.pty_write) |f| f(p.host.ctx, w.pane, w.bytes.slice()), .resize_pty => |r| if (v.pty_resize) |f| f(p.host.ctx, r.pane, r.cols, r.rows), - .signal_pty => |s| if (v.pty_signal) |f| f(p.host.ctx, s.pane, s.sig), + // A signal for a pane that closed, its slot retaken in the same + // step, would reach another pane's child. + .signal_pty => |s| if (if (p.panes[s.pane]) |pane| pane.serial != s.serial else true) {} else if (v.pty_signal) |f| f(p.host.ctx, s.pane, s.sig), .close_pty => |c| if (v.close_pty) |f| f(p.host.ctx, c.pane), .open_link => |u| if (v.open_link) |f| f(p.host.ctx, u.slice()) |
