Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/daemon.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const keys = @import("keys.zig");
const altscreen = @import("altscreen.zig");
const paths = @import("paths.zig");
const cwd = @import("cwd.zig");
const reap = @import("reap.zig");
const windowpkg = @import("window.zig");
const Window = windowpkg.Window;
const main = @import("main.zig");
Expand Down Expand Up @@ -587,11 +588,17 @@ pub const Daemon = struct {
// connecting to the dying daemon and reading EOF.
self.retireListener();
conn.send(.ok, "");
if (self.win) |w| {
posix.kill(w.child_pid, posix.SIG.HUP) catch {};
}
// Tell attached clients the session ended and flush those
// notices (and the ack above) before the teardown, so the
// kill returns and clients learn the outcome without waiting
// on a stubborn descendant's grace period.
self.broadcastExit("session terminated");
self.quitting = true;
self.drainOutbound();
// End the whole tree the session started, not just the shell,
// so a grandchild that ignores the hangup or escaped into its
// own process group cannot outlive the session and keep its
// resources (the bug in issue #97).
if (self.win) |w| reap.terminateTree(self.alloc, w.child_pid);
} else {
conn.send(.err, "unknown command");
}
Expand Down
1 change: 1 addition & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,7 @@ test {
_ = @import("cwd.zig");
_ = @import("keys.zig");
_ = @import("pty.zig");
_ = @import("reap.zig");
_ = @import("altscreen.zig");
_ = @import("oscquery.zig");
_ = @import("osc52.zig");
Expand Down
Loading
Loading