Skip to content

Commit 29cbc54

Browse files
authored
Reconnecting PTY waits for command output or EOF (#7279)
Signed-off-by: Spike Curtis <spike@coder.com>
1 parent f1dfeb0 commit 29cbc54

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

agent/agent.go

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

0 commit comments

Comments
 (0)