From 4b43a6df7acd98228b8b287eedf38ba87dc8a388 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Tue, 23 Dec 2014 22:03:20 +0000 Subject: [PATCH] add ExecIDs in inspect Signed-off-by: Victor Vieux --- daemon/exec.go | 20 +++++++++++++++++--- daemon/inspect.go | 2 ++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/daemon/exec.go b/daemon/exec.go index ecdbc58d8..92f23f738 100644 --- a/daemon/exec.go +++ b/daemon/exec.go @@ -35,7 +35,7 @@ type execConfig struct { type execStore struct { s map[string]*execConfig - sync.Mutex + sync.RWMutex } func newExecStore() *execStore { @@ -49,9 +49,9 @@ func (e *execStore) Add(id string, execConfig *execConfig) { } func (e *execStore) Get(id string) *execConfig { - e.Lock() + e.RLock() res := e.s[id] - e.Unlock() + e.RUnlock() return res } @@ -61,6 +61,16 @@ func (e *execStore) Delete(id string) { e.Unlock() } +func (e *execStore) List() []string { + var IDs []string + e.RLock() + for id, _ := range e.s { + IDs = append(IDs, id) + } + e.RUnlock() + return IDs +} + func (execConfig *execConfig) Resize(h, w int) error { return execConfig.ProcessConfig.Terminal.Resize(h, w) } @@ -249,6 +259,10 @@ func (d *Daemon) Exec(c *Container, execConfig *execConfig, pipes *execdriver.Pi return exitStatus, err } +func (container *Container) GetExecIDs() []string { + return container.execCommands.List() +} + func (container *Container) Exec(execConfig *execConfig) error { container.Lock() defer container.Unlock() diff --git a/daemon/inspect.go b/daemon/inspect.go index 2bf1773d3..37d00573b 100644 --- a/daemon/inspect.go +++ b/daemon/inspect.go @@ -50,6 +50,8 @@ func (daemon *Daemon) ContainerInspect(job *engine.Job) engine.Status { out.SetJson("VolumesRW", container.VolumesRW) out.SetJson("AppArmorProfile", container.AppArmorProfile) + out.SetList("ExecIDs", container.GetExecIDs()) + if children, err := daemon.Children(container.Name); err == nil { for linkAlias, child := range children { container.hostConfig.Links = append(container.hostConfig.Links, fmt.Sprintf("%s:%s", child.Name, linkAlias))