From bd23df8fd10acb8f84e1efedd044da053d102862 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 14 Mar 2016 16:05:45 -0700 Subject: [PATCH] Remove process dir and entry on error If we fail to exec a process make sure that it is cleaned up within the container's information and on disk state. Signed-off-by: Michael Crosby --- runtime/container_linux.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/container_linux.go b/runtime/container_linux.go index 40897fa..87e4906 100644 --- a/runtime/container_linux.go +++ b/runtime/container_linux.go @@ -164,11 +164,16 @@ func (c *container) Start(checkpoint string, s Stdio) (Process, error) { return p, nil } -func (c *container) Exec(pid string, pspec specs.ProcessSpec, s Stdio) (Process, error) { +func (c *container) Exec(pid string, pspec specs.ProcessSpec, s Stdio) (pp Process, err error) { processRoot := filepath.Join(c.root, c.id, pid) if err := os.Mkdir(processRoot, 0755); err != nil { return nil, err } + defer func() { + if err != nil { + c.RemoveProcess(pid) + } + }() cmd := exec.Command("containerd-shim", c.id, c.bundle, c.runtime, )