summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/containers/stats.go9
-rw-r--r--pkg/domain/infra/abi/containers.go1
2 files changed, 9 insertions, 1 deletions
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go
index 5b7f52cc7..c61b161e4 100644
--- a/cmd/podman/containers/stats.go
+++ b/cmd/podman/containers/stats.go
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"strings"
+ "sync"
"text/tabwriter"
"text/template"
@@ -111,14 +112,20 @@ func stats(cmd *cobra.Command, args []string) error {
}
}
statsOptions.StatChan = make(chan []*define.ContainerStats, 1)
+ wg := sync.WaitGroup{}
+ wg.Add(1)
go func() {
for reports := range statsOptions.StatChan {
if err := outputStats(reports); err != nil {
logrus.Error(err)
}
}
+ wg.Done()
+
}()
- return registry.ContainerEngine().ContainerStats(registry.Context(), args, statsOptions)
+ err := registry.ContainerEngine().ContainerStats(registry.Context(), args, statsOptions)
+ wg.Wait()
+ return err
}
func outputStats(reports []*define.ContainerStats) error {
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index b4e38ca23..e982c7c11 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -1087,6 +1087,7 @@ func (ic *ContainerEngine) Shutdown(_ context.Context) {
}
func (ic *ContainerEngine) ContainerStats(ctx context.Context, namesOrIds []string, options entities.ContainerStatsOptions) error {
+ defer close(options.StatChan)
containerFunc := ic.Libpod.GetRunningContainers
switch {
case len(namesOrIds) > 0: