Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partially revert #2723 #2749

Merged
merged 3 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions contrib/cmd/recvtty/recvtty.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ func handleSingle(path string, noStdin bool) error {
if err != nil {
return err
}
if err := console.ClearONLCR(c.Fd()); err != nil {
return err
}

// Copy from our stdio to the master fd.
var (
Expand Down
4 changes: 0 additions & 4 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,6 @@ func setupConsole(socket *os.File, config *initConfig, mount bool) error {
if err != nil {
return err
}
err = console.ClearONLCR(pty.Fd())
if err != nil {
return err
}

// After we return from here, we don't need the console anymore.
defer pty.Close()
Expand Down
9 changes: 8 additions & 1 deletion libcontainer/integration/execin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func TestExecInTTY(t *testing.T) {
if testing.Short() {
return
}
t.Skip("racy; see https://github.com/opencontainers/runc/issues/2425")
rootfs, err := newRootfs()
ok(t, err)
defer remove(rootfs)
Expand Down Expand Up @@ -285,7 +286,6 @@ func TestExecInTTY(t *testing.T) {
}()
ok(t, err)

var stdout bytes.Buffer
ps := &libcontainer.Process{
Cwd: "/",
Args: []string{"ps"},
Expand All @@ -295,6 +295,8 @@ func TestExecInTTY(t *testing.T) {
// Repeat to increase chances to catch a race; see
// https://github.com/opencontainers/runc/issues/2425.
for i := 0; i < 300; i++ {
var stdout bytes.Buffer

parent, child, err := utils.NewSockPair("console")
if err != nil {
ok(t, err)
Expand All @@ -313,6 +315,11 @@ func TestExecInTTY(t *testing.T) {
done <- fmt.Errorf("ConsoleFromFile: %w", err)
return
}
err = console.ClearONLCR(c.Fd())
if err != nil {
done <- fmt.Errorf("ClearONLCR: %w", err)
return
}
// An error from io.Copy is expected once the terminal
// is gone, so we deliberately ignore it.
_, _ = io.Copy(&stdout, c)
Expand Down
4 changes: 4 additions & 0 deletions tty.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ func (t *tty) recvtty(process *libcontainer.Process, socket *os.File) (Err error
if err != nil {
return err
}
err = console.ClearONLCR(cons.Fd())
if err != nil {
return err
}
epoller, err := console.NewEpoller()
if err != nil {
return err
Expand Down