diff options
author | Paul Holzinger <pholzing@redhat.com> | 2022-09-12 14:22:27 +0200 |
---|---|---|
committer | Paul Holzinger <pholzing@redhat.com> | 2022-09-12 18:05:18 +0200 |
commit | 2ae4ce79996097fb0a403abbb9be9ef7b5c02d80 (patch) | |
tree | 54615dd393b1759a10ba8f271627d972517d795c /cmd/podman/system | |
parent | b3212a6802b9a9dd5311dcbebe68c9c67fd96218 (diff) | |
download | podman-2ae4ce79996097fb0a403abbb9be9ef7b5c02d80.tar.gz podman-2ae4ce79996097fb0a403abbb9be9ef7b5c02d80.tar.bz2 podman-2ae4ce79996097fb0a403abbb9be9ef7b5c02d80.zip |
fix race where podman events exits to early
In order to display all events we have to read until the event channel
is closed.
Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'cmd/podman/system')
-rw-r--r-- | cmd/podman/system/events.go | 16 |
1 files changed, 11 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 + } } } } |