diff --git a/libpod/container_log.go b/libpod/container_log.go index ea76c7ea39..91c0a50ccf 100644 --- a/libpod/container_log.go +++ b/libpod/container_log.go @@ -10,7 +10,6 @@ import ( "time" "github.com/containers/podman/v5/libpod/define" - "github.com/containers/podman/v5/libpod/events" "github.com/containers/podman/v5/libpod/logs" systemdDefine "github.com/containers/podman/v5/pkg/systemd/define" "github.com/nxadm/tail" @@ -139,20 +138,10 @@ func (c *Container) readFromLogFile(ctx context.Context, options *logs.LogOption // The container is running, so we need to wait until the container exited go func() { - eventChannel := make(chan *events.Event) - eventOptions := events.ReadOptions{ - EventChannel: eventChannel, - Filters: []string{"event=died", "container=" + c.ID()}, - Stream: true, + _, err = c.Wait(ctx) + if err != nil && !errors.Is(err, define.ErrNoSuchCtr) { + logrus.Errorf("Waiting for container to exit: %v", err) } - go func() { - if err := c.runtime.Events(ctx, eventOptions); err != nil { - logrus.Errorf("Waiting for container to exit: %v", err) - } - }() - // Now wait for the died event and signal to finish - // reading the log until EOF. - <-eventChannel // Make sure to wait at least for the poll duration // before stopping the file logger (see #10675). time.Sleep(watch.POLL_DURATION)