summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/system/events.go39
1 files changed, 21 insertions, 18 deletions
diff --git a/cmd/podman/system/events.go b/cmd/podman/system/events.go
index 3c6a35e83..57279bb02 100644
--- a/cmd/podman/system/events.go
+++ b/cmd/podman/system/events.go
@@ -99,25 +99,28 @@ func eventsCmd(cmd *cobra.Command, _ []string) error {
errChannel <- err
}()
- for event := range eventChannel {
- switch {
- case event == nil:
- // no-op
- case doJSON:
- jsonStr, err := event.ToJSONString()
- if err != nil {
- return err
+ for {
+ select {
+ case err := <-errChannel:
+ return err
+ case event := <-eventChannel:
+ switch {
+ case event == nil:
+ // no-op
+ case doJSON:
+ jsonStr, err := event.ToJSONString()
+ if err != nil {
+ return err
+ }
+ fmt.Println(jsonStr)
+ case cmd.Flags().Changed("format"):
+ if err := rpt.Execute(event); err != nil {
+ return err
+ }
+ os.Stdout.WriteString("\n")
+ default:
+ fmt.Println(event.ToHumanReadable(!noTrunc))
}
- fmt.Println(jsonStr)
- case cmd.Flags().Changed("format"):
- if err := rpt.Execute(event); err != nil {
- return err
- }
- os.Stdout.WriteString("\n")
- default:
- fmt.Println(event.ToHumanReadable(!noTrunc))
}
}
-
- return <-errChannel
}