Skip to content

Commit 9141f7c

Browse files
spikecurtismtojek
authored andcommitted
Reconnecting PTY waits for command output or EOF (#7279)
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent 5f6b4dc commit 9141f7c

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

agent/agent.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,12 +1035,9 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m
10351035
<-ctx.Done()
10361036
_ = process.Kill()
10371037
}()
1038-
go func() {
1039-
// If the process dies randomly, we should
1040-
// close the pty.
1041-
_ = process.Wait()
1042-
rpty.Close()
1043-
}()
1038+
// We don't need to separately monitor for the process exiting.
1039+
// When it exits, our ptty.OutputReader() will return EOF after
1040+
// reading all process output.
10441041
if err = a.trackConnGoroutine(func() {
10451042
buffer := make([]byte, 1024)
10461043
for {

0 commit comments

Comments
 (0)