Skip to content

Commit

Permalink
containers/attach: Note bug around goroutine leak
Browse files Browse the repository at this point in the history
See:

- containers/podman-bootc#59 (comment)
- containers/podman-bootc#61

Sorry for not trying to fix this, but I am not aware of
a remotely straightforward way to do so.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Jul 9, 2024
1 parent b3afb8f commit 4336c5a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/bindings/containers/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ type CloseWriter interface {
CloseWrite() error
}

// Attach attaches to a running container
// Attach attaches to a running container.
//
// NOTE: When stdin is provided, this function currently leaks a goroutine reading from that stream
// even if the ctx is cancelled. The goroutine will only exit if the input stream is closed. For example,
// if stdin is `os.Stdin` attached to a tty, the goroutine will consume a chunk of user input from the
// terminal even after the container has exited. In this scenario the os.Stdin stream will not be expected
// to be closed.
func Attach(ctx context.Context, nameOrID string, stdin io.Reader, stdout io.Writer, stderr io.Writer, attachReady chan bool, options *AttachOptions) error {
if options == nil {
options = new(AttachOptions)
Expand Down

0 comments on commit 4336c5a

Please sign in to comment.