diff --git a/src/shell/subproc.zig b/src/shell/subproc.zig index d910d9332a..28f068d3a0 100644 --- a/src/shell/subproc.zig +++ b/src/shell/subproc.zig @@ -1228,7 +1228,11 @@ pub const PipeReader = struct { const owned = this.toOwnedSlice(); this.state = .{ .done = owned }; if (!this.isDone()) return; + // we need to ref because the process might be done and deref inside signalDoneToCmd before we call onCloseIO + this.ref(); + defer this.deref(); this.signalDoneToCmd(); + if (this.process) |process| { // this.process = null; process.onCloseIO(this.kind(process));