mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
runc exec: reject paused container unless --ignore-paused
Currently, if a container is paused (i.e. its cgroup is frozen), runc exec just hangs, and it is not obvious why. Refuse to exec in a paused container. Add a test case. In case runc exec in a paused container is a legit use case, add --ignore-paused option to override the check. Document it, add a test case. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -91,6 +91,10 @@ following will output a list of processes running in the container:
|
||||
Name: "cgroup",
|
||||
Usage: "run the process in an (existing) sub-cgroup(s). Format is [<controller>:]<cgroup>.",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "ignore-paused",
|
||||
Usage: "allow exec in a paused container",
|
||||
},
|
||||
},
|
||||
Action: func(context *cli.Context) error {
|
||||
if err := checkArgs(context, 1, minArgs); err != nil {
|
||||
@@ -145,7 +149,10 @@ func execProcess(context *cli.Context) (int, error) {
|
||||
return -1, err
|
||||
}
|
||||
if status == libcontainer.Stopped {
|
||||
return -1, errors.New("cannot exec a container that has stopped")
|
||||
return -1, errors.New("cannot exec in a stopped container")
|
||||
}
|
||||
if status == libcontainer.Paused && !context.Bool("ignore-paused") {
|
||||
return -1, errors.New("cannot exec in a paused container (use --ignore-paused to override)")
|
||||
}
|
||||
path := context.String("process")
|
||||
if path == "" && len(context.Args()) == 1 {
|
||||
|
||||
Reference in New Issue
Block a user