示例#1
0
文件: exec.go 项目: hwpaas/docker
// SetupCgroups applies the cgroup restrictions to the process running in the container based
// on the container's configuration
func SetupCgroups(container *libcontainer.Config, nspid int) (cgroups.ActiveCgroup, error) {
	if container.Cgroups != nil {
		c := container.Cgroups
		if systemd.UseSystemd() {
			return systemd.Apply(c, nspid)
		}
		return fs.Apply(c, nspid)
	}
	return nil, nil
}
示例#2
0
文件: exec.go 项目: hgschmie/docker
// SetupCgroups applies the cgroup restrictions to the process running in the container based
// on the container's configuration
func SetupCgroups(container *libcontainer.Config, nspid int) (map[string]string, error) {
	if container.Cgroups != nil {
		c := container.Cgroups
		if systemd.UseSystemd() {
			return systemd.Apply(c, nspid)
		}
		return fs.Apply(c, nspid)
	}
	return map[string]string{}, nil
}
示例#3
0
文件: cgutil.go 项目: BreezeWu/docker
func createAction(context *cli.Context) {
	config, err := getConfigFromFile(context)
	if err != nil {
		log.Fatal(err)
	}
	pid := context.Int("pid")
	if pid <= 0 {
		log.Fatal(fmt.Errorf("Invalid pid : %d", pid))
	}
	if systemd.UseSystemd() {
		_, err := systemd.Apply(config, pid)
		if err != nil {
			log.Fatal(err)
		}
	} else {
		_, err := fs.Apply(config, pid)
		if err != nil {
			log.Fatal(err)
		}
	}
}