mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
runsc: Pass controlling TTY by FD in the *new* process, not current process.
When setting Cmd.SysProcAttr.Ctty, the FD must be the FD of the controlling TTY in the new process, not the current process. The ioctl call is made after duping all FDs in Cmd.ExtraFiles, which may stomp on the old TTY FD. This fixes the "bad address" flakes in runsc/container:container_test, although some other flakes remain. PiperOrigin-RevId: 216594394 Change-Id: Idfd1677abb866aa82ad7e8be776f0c9087256862
This commit is contained in:
committed by
Shentubot
parent
8388a505e7
commit
1939cd020f
@@ -363,11 +363,6 @@ func (s *Sandbox) createSandboxProcess(spec *specs.Spec, conf *boot.Config, bund
|
||||
return fmt.Errorf("error setting up console with socket %q: %v", consoleSocket, err)
|
||||
}
|
||||
defer tty.Close()
|
||||
fd := int(tty.Fd())
|
||||
|
||||
// Set the TTY as a controlling TTY on the sandbox process.
|
||||
cmd.SysProcAttr.Setctty = true
|
||||
cmd.SysProcAttr.Ctty = fd
|
||||
|
||||
// Ideally we would set the sandbox stdin to this process'
|
||||
// stdin, but for some reason Docker does not like that (it
|
||||
@@ -378,6 +373,13 @@ func (s *Sandbox) createSandboxProcess(spec *specs.Spec, conf *boot.Config, bund
|
||||
cmd.Stdout = tty
|
||||
cmd.Stderr = tty
|
||||
|
||||
// Set the TTY as a controlling TTY on the sandbox process.
|
||||
// Note that the Ctty field must be the FD of the TTY in the
|
||||
// *new* process, not this process. Since we set the TTY to
|
||||
// stdin, we can use FD 0 here.
|
||||
cmd.SysProcAttr.Setctty = true
|
||||
cmd.SysProcAttr.Ctty = 0
|
||||
|
||||
// Pass the tty as all stdio fds to sandbox.
|
||||
for i := 0; i < 3; i++ {
|
||||
cmd.ExtraFiles = append(cmd.ExtraFiles, tty)
|
||||
|
||||
Reference in New Issue
Block a user