From e0da28acc4c58d10e62c5328fc10070ba524511d Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 24 Oct 2017 05:23:55 +0900 Subject: [PATCH] ctr: error if tty && nullIO Signed-off-by: Akihiro Suda --- cmd/ctr/run_unix.go | 4 ++++ cmd/ctr/run_windows.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cmd/ctr/run_unix.go b/cmd/ctr/run_unix.go index c890a61a5..266ded039 100644 --- a/cmd/ctr/run_unix.go +++ b/cmd/ctr/run_unix.go @@ -12,6 +12,7 @@ import ( "github.com/containerd/console" "github.com/containerd/containerd" specs "github.com/opencontainers/runtime-spec/specs-go" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/urfave/cli" ) @@ -121,6 +122,9 @@ func newTask(ctx gocontext.Context, client *containerd.Client, container contain io = containerd.StdioTerminal } if nullIO { + if tty { + return nil, errors.New("tty and null-io cannot be used together") + } io = containerd.NullIO } return container.NewTask(ctx, io) diff --git a/cmd/ctr/run_windows.go b/cmd/ctr/run_windows.go index 2879faec6..5141521fc 100644 --- a/cmd/ctr/run_windows.go +++ b/cmd/ctr/run_windows.go @@ -123,6 +123,9 @@ func newTask(ctx gocontext.Context, client *containerd.Client, container contain io = containerd.StdioTerminal } if nullIO { + if tty { + return nil, errors.New("tty and null-io cannot be used together") + } io = containerd.NullIO } return container.NewTask(ctx, io)