From 98d63504a40f58e22708177aefe9d6134f85b112 Mon Sep 17 00:00:00 2001 From: rajasec Date: Fri, 3 Jun 2016 23:42:14 +0530 Subject: [PATCH] Not exec a container from stopped state Signed-off-by: rajasec --- exec.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/exec.go b/exec.go index f3a22e09187..d9c34c06563 100644 --- a/exec.go +++ b/exec.go @@ -9,6 +9,7 @@ import ( "strconv" "strings" + "github.com/opencontainers/runc/libcontainer" "github.com/opencontainers/runc/libcontainer/utils" "github.com/opencontainers/runtime-spec/specs-go" "github.com/urfave/cli" @@ -101,6 +102,13 @@ func execProcess(context *cli.Context) (int, error) { if err != nil { return -1, err } + status, err := container.Status() + if err != nil { + return -1, err + } + if status == libcontainer.Stopped { + return -1, fmt.Errorf("cannot exec a container that has run and stopped") + } path := context.String("process") if path == "" && len(context.Args()) == 1 { return -1, fmt.Errorf("process args cannot be empty")