diff options
Diffstat (limited to 'src/tty/tty.zig')
| -rw-r--r-- | src/tty/tty.zig | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig index b2768ed6..128a7ead 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -1007,6 +1007,7 @@ const Shell = struct { if (s.ptys[e.id]) |*pt| { pt.reader.await(s.io) catch {}; // reader just finished; join it or its future leaks _ = libc.close(pt.file.handle); + host_io.retireShell(pt.pid); s.ptys[e.id] = null; } core.update(.{ .eof = .{ .pane = @intCast(e.id) } }); @@ -1193,11 +1194,7 @@ const Shell = struct { fn spawn(ctx: ?*anyopaque, pane: u8, cwd: []const u8) void { const s = of(ctx); - if (s.ptys[pane]) |*old| { - old.reader.cancel(s.io) catch {}; - _ = libc.close(old.file.handle); - s.ptys[pane] = null; - } + closePty(ctx, pane); // a shell still in the slot goes first, reaped s.gens[pane] +%= 1; const child = host_io.forkShell(s.core, pane, s.prompt_rcs, s.core.shellBin(), cwd, s.core.screen_h, s.core.screen_w, s.fs) catch |err| return s.core.reportError(pane, "shell", err); s.ptys[pane] = .{ .file = child.file, .pid = child.pid, .reader = .{ .any_future = null, .result = {} } }; @@ -1229,8 +1226,8 @@ const Shell = struct { } /// The pane is gone: hang its pty up, which the kernel passes on to the - /// shell as SIGHUP, and say it too for a shell that ignores the tty's. - /// Output still in flight carries the old generation and is dropped. + /// shell as SIGHUP, and retire the shell. Output still in flight + /// carries the old generation and is dropped. fn closePty(ctx: ?*anyopaque, pane: u8) void { const s = of(ctx); var pt = s.ptys[pane] orelse return; @@ -1238,8 +1235,7 @@ const Shell = struct { s.gens[pane] +%= 1; pt.reader.cancel(s.io) catch {}; _ = libc.close(pt.file.handle); - _ = libc.kill(pt.pid, posix.SIG.HUP); - _ = libc.waitpid(pt.pid, null, posix.W.NOHANG); + host_io.retireShell(pt.pid); } fn ttyTaken(ctx: ?*anyopaque, pane: u8) bool { |
