Skip to content

Commit e47acc3

Browse files
authored
Merge pull request #4054 from apostasie/fix-raw
[fix] Avoid console SetRaw
2 parents 0881ccb + a1dc0e2 commit e47acc3

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

cmd/nerdctl/container/container_run.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"strings"
2424

2525
"github.com/spf13/cobra"
26+
"golang.org/x/term"
2627

2728
"github.com/containerd/console"
2829
"github.com/containerd/log"
@@ -407,7 +408,7 @@ func runAction(cmd *cobra.Command, args []string) error {
407408
return err
408409
}
409410
defer con.Reset()
410-
if err := con.SetRaw(); err != nil {
411+
if _, err := term.MakeRaw(int(con.Fd())); err != nil {
411412
return err
412413
}
413414
}

pkg/cmd/container/attach.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"errors"
2222
"fmt"
2323

24+
"golang.org/x/term"
25+
2426
"github.com/containerd/console"
2527
containerd "github.com/containerd/containerd/v2/client"
2628
"github.com/containerd/containerd/v2/pkg/cio"
@@ -93,7 +95,8 @@ func Attach(ctx context.Context, client *containerd.Client, req string, options
9395
return err
9496
}
9597
defer con.Reset()
96-
if err := con.SetRaw(); err != nil {
98+
99+
if _, err := term.MakeRaw(int(con.Fd())); err != nil {
97100
return fmt.Errorf("failed to set the console to raw mode: %w", err)
98101
}
99102
closer := func() {

pkg/cmd/container/exec.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"os"
2424

2525
"github.com/opencontainers/runtime-spec/specs-go"
26+
"golang.org/x/term"
2627

2728
"github.com/containerd/console"
2829
containerd "github.com/containerd/containerd/v2/client"
@@ -111,7 +112,7 @@ func execActionWithContainer(ctx context.Context, client *containerd.Client, con
111112
return err
112113
}
113114
defer con.Reset()
114-
if err := con.SetRaw(); err != nil {
115+
if _, err := term.MakeRaw(int(con.Fd())); err != nil {
115116
return err
116117
}
117118
}

pkg/containerutil/containerutil.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
dockeropts "github.com/docker/docker/opts"
3434
"github.com/moby/sys/signal"
3535
"github.com/opencontainers/runtime-spec/specs-go"
36+
"golang.org/x/term"
3637

3738
"github.com/containerd/console"
3839
containerd "github.com/containerd/containerd/v2/client"
@@ -248,7 +249,7 @@ func Start(ctx context.Context, container containerd.Container, flagA bool, clie
248249
return err
249250
}
250251
defer con.Reset()
251-
if err := con.SetRaw(); err != nil {
252+
if _, err := term.MakeRaw(int(con.Fd())); err != nil {
252253
return err
253254
}
254255
}

0 commit comments

Comments
 (0)