summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2018-10-03 10:31:01 -0700
committerShentubot <shentubot@google.com>2018-10-03 10:32:03 -0700
commite215b9970ad82915a8d544b81b3c49d7d84a0eb0 (patch)
treeca7fafed97a41307243ab7fc84d0a19e285dee53 /runsc/boot
parent77e43adeab4abcd301d76222e0304f551fbcf0cc (diff)
runsc: Pass root container's stdio via FD.
We were previously using the sandbox process's stdio as the root container's stdio. This makes it difficult/impossible to distinguish output application output from sandbox output, such as panics, which are always written to stderr. Also close the console socket when we are done with it. PiperOrigin-RevId: 215585180 Change-Id: I980b8c69bd61a8b8e0a496fd7bc90a06446764e0
Diffstat (limited to 'runsc/boot')
-rw-r--r--runsc/boot/loader.go6
-rw-r--r--runsc/boot/loader_test.go3
2 files changed, 5 insertions, 4 deletions
diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go
index 766a2e968..726482bb2 100644
--- a/runsc/boot/loader.go
+++ b/runsc/boot/loader.go
@@ -140,7 +140,7 @@ func init() {
// New initializes a new kernel loader configured by spec.
// New also handles setting up a kernel for restoring a container.
-func New(id string, spec *specs.Spec, conf *Config, controllerFD, deviceFD int, goferFDs []int, console bool) (*Loader, error) {
+func New(id string, spec *specs.Spec, conf *Config, controllerFD, deviceFD int, goferFDs []int, stdioFDs []int, console bool) (*Loader, error) {
if err := usage.Init(); err != nil {
return nil, fmt.Errorf("Error setting up memory usage: %v", err)
}
@@ -279,9 +279,9 @@ func New(id string, spec *specs.Spec, conf *Config, controllerFD, deviceFD int,
conf: conf,
console: console,
watchdog: watchdog,
- stdioFDs: []int{syscall.Stdin, syscall.Stdout, syscall.Stderr},
- goferFDs: goferFDs,
spec: spec,
+ goferFDs: goferFDs,
+ stdioFDs: stdioFDs,
startSignalForwarding: startSignalForwarding,
rootProcArgs: procArgs,
sandboxID: id,
diff --git a/runsc/boot/loader_test.go b/runsc/boot/loader_test.go
index 0b363253d..ea8411a8b 100644
--- a/runsc/boot/loader_test.go
+++ b/runsc/boot/loader_test.go
@@ -101,7 +101,8 @@ func createLoader() (*Loader, func(), error) {
return nil, nil, err
}
- l, err := New("foo", spec, conf, fd, -1 /* device fd */, []int{sandEnd}, false)
+ stdio := []int{int(os.Stdin.Fd()), int(os.Stdout.Fd()), int(os.Stderr.Fd())}
+ l, err := New("foo", spec, conf, fd, -1 /* device fd */, []int{sandEnd}, stdio, false)
if err != nil {
cleanup()
return nil, nil, err