summaryrefslogtreecommitdiffhomepage
path: root/runsc/boot/loader_test.go
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-04-14 11:20:11 -0700
committergVisor bot <gvisor-bot@google.com>2020-04-14 11:20:11 -0700
commitac9b32c36b40e51a77e44c0b82ecd349d77a4379 (patch)
treedc6a23f210030adae6acb1e725e5ac9a5a0e152d /runsc/boot/loader_test.go
parent81c44c4cd7cfa121d9ef028db18b3ee550845811 (diff)
parent0cfdd47391d30dfe8214e2d11bdad9b27419ad26 (diff)
Merge pull request #2212 from aaronlu:dup_stdioFDs
PiperOrigin-RevId: 306477639
Diffstat (limited to 'runsc/boot/loader_test.go')
-rw-r--r--runsc/boot/loader_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/runsc/boot/loader_test.go b/runsc/boot/loader_test.go
index 44aa63196..c9a75b76d 100644
--- a/runsc/boot/loader_test.go
+++ b/runsc/boot/loader_test.go
@@ -24,6 +24,7 @@ import (
"time"
specs "github.com/opencontainers/runtime-spec/specs-go"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/control/server"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/p9"
@@ -113,7 +114,16 @@ func createLoader() (*Loader, func(), error) {
return nil, nil, err
}
- stdio := []int{int(os.Stdin.Fd()), int(os.Stdout.Fd()), int(os.Stderr.Fd())}
+ // Loader takes ownership of stdio.
+ var stdio []int
+ for _, f := range []*os.File{os.Stdin, os.Stdout, os.Stderr} {
+ newFd, err := unix.Dup(int(f.Fd()))
+ if err != nil {
+ return nil, nil, err
+ }
+ stdio = append(stdio, newFd)
+ }
+
args := Args{
ID: "foo",
Spec: spec,