diff options
-rw-r--r-- | cmd/podman/system/events.go | 16 | ||||
-rw-r--r-- | test/system/090-events.bats | 1 |
2 files changed, 12 insertions, 5 deletions
diff --git a/cmd/podman/system/events.go b/cmd/podman/system/events.go index 57279bb02..693af3e60 100644 --- a/cmd/podman/system/events.go +++ b/cmd/podman/system/events.go @@ -101,12 +101,12 @@ func eventsCmd(cmd *cobra.Command, _ []string) error { for { select { - case err := <-errChannel: - return err - case event := <-eventChannel: + case event, ok := <-eventChannel: + if !ok { + // channel was closed we can exit + return nil + } switch { - case event == nil: - // no-op case doJSON: jsonStr, err := event.ToJSONString() if err != nil { @@ -121,6 +121,12 @@ func eventsCmd(cmd *cobra.Command, _ []string) error { default: fmt.Println(event.ToHumanReadable(!noTrunc)) } + case err := <-errChannel: + // only exit in case of an error, + // otherwise keep reading events until the event channel is closed + if err != nil { + return err + } } } } diff --git a/test/system/090-events.bats b/test/system/090-events.bats index 509e7a306..3fac51938 100644 --- a/test/system/090-events.bats +++ b/test/system/090-events.bats @@ -74,6 +74,7 @@ load helpers .*image tag $imageID $tag .*image untag $imageID $tag:latest .*image tag $imageID $tag +.*image untag $imageID $IMAGE .*image untag $imageID $tag:latest .*image remove $imageID $imageID" \ "podman events" |