summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-03-02 08:38:52 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-02 15:51:58 +0000
commit0c4a276a04e8d9344571aa30dcab966f7096dcdc (patch)
tree547b75dac208d140a862d7f037d2393a96866361 /cmd
parent656840c9924b0348c7e939b4215f14c5b076842f (diff)
downloadpodman-0c4a276a04e8d9344571aa30dcab966f7096dcdc.tar.gz
podman-0c4a276a04e8d9344571aa30dcab966f7096dcdc.tar.bz2
podman-0c4a276a04e8d9344571aa30dcab966f7096dcdc.zip
podman logs -f: does not detect container stop or rm
If a container stops, we should stop the logging capability and gracefully exit. However, if the container pauses, we should allow the log to continue. Resolves issue: #435 Signed-off-by: baude <bbaude@redhat.com> Closes: #437 Approved by: baude
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/logs.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/podman/logs.go b/cmd/podman/logs.go
index 07d95aaf8..1183abaa2 100644
--- a/cmd/podman/logs.go
+++ b/cmd/podman/logs.go
@@ -129,14 +129,14 @@ func logsCmd(c *cli.Context) error {
defer file.Close()
reader := bufio.NewReader(file)
if opts.follow {
- followLog(reader, opts)
+ followLog(reader, opts, ctr)
} else {
dumpLog(reader, opts)
}
return err
}
-func followLog(reader *bufio.Reader, opts logOptions) error {
+func followLog(reader *bufio.Reader, opts logOptions, ctr *libpod.Container) error {
var cacheOutput []string
firstPass := false
if opts.tail > 0 {
@@ -161,6 +161,14 @@ func followLog(reader *bufio.Reader, opts logOptions) error {
continue
}
time.Sleep(1 * time.Second)
+ // Check if container is still running or paused
+ state, err := ctr.State()
+ if err != nil {
+ return err
+ }
+ if state != libpod.ContainerStateRunning && state != libpod.ContainerStatePaused {
+ break
+ }
continue
}
// exits