From 29cbc5404ae402fa07c44d0ad9851ea6c087f0e6 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 26 Apr 2023 09:02:06 +0400 Subject: [PATCH] Reconnecting PTY waits for command output or EOF (#7279) Signed-off-by: Spike Curtis --- agent/agent.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 9b70506b49..82f06e66fa 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -1036,12 +1036,9 @@ func (a *agent) handleReconnectingPTY(ctx context.Context, logger slog.Logger, m <-ctx.Done() _ = process.Kill() }() - go func() { - // If the process dies randomly, we should - // close the pty. - _ = process.Wait() - rpty.Close() - }() + // We don't need to separately monitor for the process exiting. + // When it exits, our ptty.OutputReader() will return EOF after + // reading all process output. if err = a.trackConnGoroutine(func() { buffer := make([]byte, 1024) for {