Skip to content

Commit

Permalink
Merge pull request #880 from rajasec/exec-status
Browse files Browse the repository at this point in the history
Not exec a container from stopped state
  • Loading branch information
hqhq authored Aug 27, 2016
2 parents dc9be6c + 98d6350 commit face64a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit face64a

Please sign in to comment.