mirror of
https://github.com/weaveworks/scope.git
synced 2026-05-11 11:47:32 +00:00
``` $ gvt delete github.com/opencontainers/runc/libcontainer/cgroups $ gvt delete github.com/opencontainers/runc/libcontainer/configs $ gvt delete github.com/opencontainers/runc/libcontainer/system $ gvt delete github.com/opencontainers/runc/libcontainer/user $ gvt delete github.com/opencontainers/runc/libcontainer/utils $ gvt fetch --tag v1.0.0-rc5 github.com/opencontainers/runc/libcontainer 2018/07/23 17:08:18 Fetching: github.com/opencontainers/runc/libcontainer 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/vishvananda/netlink 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/golang.org/x/sys/unix 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/cyphar/filepath-securejoin 2018/07/23 17:08:24 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/pkg/errors 2018/07/23 17:08:24 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/opencontainers/selinux/go-selinux/label 2018/07/23 17:08:25 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/opencontainers/selinux/go-selinux 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/containerd/console 2018/07/23 17:08:25 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/golang.org/x/sys/windows 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/sirupsen/logrus 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/godbus/dbus 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/mrunalp/fileutils 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/coreos/go-systemd/util 2018/07/23 17:08:25 ·· Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/coreos/pkg/dlopen 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/golang/protobuf/proto 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/syndtr/gocapability/capability 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/coreos/go-systemd/dbus 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/opencontainers/runtime-spec/specs-go 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/seccomp/libseccomp-golang 2018/07/23 17:08:25 · Fetching recursive dependency: github.com/opencontainers/runc/vendor/github.com/docker/go-units ```
123 lines
2.6 KiB
Go
123 lines
2.6 KiB
Go
// +build linux
|
|
|
|
package libcontainer
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/system"
|
|
)
|
|
|
|
func newRestoredProcess(pid int, fds []string) (*restoredProcess, error) {
|
|
var (
|
|
err error
|
|
)
|
|
proc, err := os.FindProcess(pid)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
stat, err := system.Stat(pid)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &restoredProcess{
|
|
proc: proc,
|
|
processStartTime: stat.StartTime,
|
|
fds: fds,
|
|
}, nil
|
|
}
|
|
|
|
type restoredProcess struct {
|
|
proc *os.Process
|
|
processStartTime uint64
|
|
fds []string
|
|
}
|
|
|
|
func (p *restoredProcess) start() error {
|
|
return newGenericError(fmt.Errorf("restored process cannot be started"), SystemError)
|
|
}
|
|
|
|
func (p *restoredProcess) pid() int {
|
|
return p.proc.Pid
|
|
}
|
|
|
|
func (p *restoredProcess) terminate() error {
|
|
err := p.proc.Kill()
|
|
if _, werr := p.wait(); err == nil {
|
|
err = werr
|
|
}
|
|
return err
|
|
}
|
|
|
|
func (p *restoredProcess) wait() (*os.ProcessState, error) {
|
|
// TODO: how do we wait on the actual process?
|
|
// maybe use --exec-cmd in criu
|
|
st, err := p.proc.Wait()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return st, nil
|
|
}
|
|
|
|
func (p *restoredProcess) startTime() (uint64, error) {
|
|
return p.processStartTime, nil
|
|
}
|
|
|
|
func (p *restoredProcess) signal(s os.Signal) error {
|
|
return p.proc.Signal(s)
|
|
}
|
|
|
|
func (p *restoredProcess) externalDescriptors() []string {
|
|
return p.fds
|
|
}
|
|
|
|
func (p *restoredProcess) setExternalDescriptors(newFds []string) {
|
|
p.fds = newFds
|
|
}
|
|
|
|
// nonChildProcess represents a process where the calling process is not
|
|
// the parent process. This process is created when a factory loads a container from
|
|
// a persisted state.
|
|
type nonChildProcess struct {
|
|
processPid int
|
|
processStartTime uint64
|
|
fds []string
|
|
}
|
|
|
|
func (p *nonChildProcess) start() error {
|
|
return newGenericError(fmt.Errorf("restored process cannot be started"), SystemError)
|
|
}
|
|
|
|
func (p *nonChildProcess) pid() int {
|
|
return p.processPid
|
|
}
|
|
|
|
func (p *nonChildProcess) terminate() error {
|
|
return newGenericError(fmt.Errorf("restored process cannot be terminated"), SystemError)
|
|
}
|
|
|
|
func (p *nonChildProcess) wait() (*os.ProcessState, error) {
|
|
return nil, newGenericError(fmt.Errorf("restored process cannot be waited on"), SystemError)
|
|
}
|
|
|
|
func (p *nonChildProcess) startTime() (uint64, error) {
|
|
return p.processStartTime, nil
|
|
}
|
|
|
|
func (p *nonChildProcess) signal(s os.Signal) error {
|
|
proc, err := os.FindProcess(p.processPid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return proc.Signal(s)
|
|
}
|
|
|
|
func (p *nonChildProcess) externalDescriptors() []string {
|
|
return p.fds
|
|
}
|
|
|
|
func (p *nonChildProcess) setExternalDescriptors(newFds []string) {
|
|
p.fds = newFds
|
|
}
|