Skip to content

Commit c7978db

Browse files
committed
Move lifecycle after buffer and process are set
The lifecycle will try to close the process (and before it would clear the buffer as well) so they need to be set.
1 parent 61a4253 commit c7978db

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

agent/reconnectingpty/buffered.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ func newBuffered(ctx context.Context, cmd *pty.Cmd, options *Options, logger slo
5252
timeout: options.Timeout,
5353
}
5454

55-
go rpty.lifecycle(ctx, logger)
56-
5755
// Default to buffer 64KiB.
5856
circularBuffer, err := circbuf.NewBuffer(64 << 10)
5957
if err != nil {
@@ -75,6 +73,8 @@ func newBuffered(ctx context.Context, cmd *pty.Cmd, options *Options, logger slo
7573
rpty.ptty = ptty
7674
rpty.process = process
7775

76+
go rpty.lifecycle(ctx, logger)
77+
7878
// Multiplex the output onto the circular buffer and each active connection.
7979
// We do not need to separately monitor for the process exiting. When it
8080
// exits, our ptty.OutputReader() will return EOF after reading all process
@@ -125,7 +125,7 @@ func newBuffered(ctx context.Context, cmd *pty.Cmd, options *Options, logger slo
125125
}
126126

127127
// lifecycle manages the lifecycle of the reconnecting pty. If the context ends
128-
// the reconnecting pty will be closed.
128+
// the reconnecting pty and every connection will be closed.
129129
func (rpty *bufferedReconnectingPTY) lifecycle(ctx context.Context, logger slog.Logger) {
130130
rpty.timer = time.AfterFunc(attachTimeout, func() {
131131
rpty.Close("reconnecting pty timeout")

0 commit comments

Comments
 (0)