... | ... |
@@ -40,9 +40,7 @@ type Container struct { |
40 | 40 |
stdin io.ReadCloser |
41 | 41 |
stdinPipe io.WriteCloser |
42 | 42 |
|
43 |
- ptyStdinMaster io.Closer |
|
44 |
- ptyStdoutMaster io.Closer |
|
45 |
- ptyStderrMaster io.Closer |
|
43 |
+ ptyMaster io.Closer |
|
46 | 44 |
|
47 | 45 |
runtime *Runtime |
48 | 46 |
} |
... | ... |
@@ -180,40 +178,37 @@ func (container *Container) generateLXCConfig() error { |
180 | 180 |
} |
181 | 181 |
|
182 | 182 |
func (container *Container) startPty() error { |
183 |
- |
|
184 |
- stdoutMaster, stdoutSlave, err := pty.Open() |
|
183 |
+ ptyMaster, ptySlave, err := pty.Open() |
|
185 | 184 |
if err != nil { |
186 | 185 |
return err |
187 | 186 |
} |
188 |
- container.ptyStdoutMaster = stdoutMaster |
|
189 |
- container.cmd.Stdout = stdoutSlave |
|
190 |
- container.cmd.Stderr = stdoutSlave |
|
187 |
+ container.ptyMaster = ptyMaster |
|
188 |
+ container.cmd.Stdout = ptySlave |
|
189 |
+ container.cmd.Stderr = ptySlave |
|
191 | 190 |
|
192 | 191 |
// Copy the PTYs to our broadcasters |
193 | 192 |
go func() { |
194 | 193 |
defer container.stdout.CloseWriters() |
195 | 194 |
Debugf("[startPty] Begin of stdout pipe") |
196 |
- io.Copy(container.stdout, stdoutMaster) |
|
195 |
+ io.Copy(container.stdout, ptyMaster) |
|
197 | 196 |
Debugf("[startPty] End of stdout pipe") |
198 | 197 |
}() |
199 | 198 |
|
200 | 199 |
// stdin |
201 | 200 |
if container.Config.OpenStdin { |
202 |
- container.cmd.Stdin = stdoutSlave |
|
203 |
- // FIXME: The following appears to be broken. |
|
204 |
- // "cannot set terminal process group (-1): Inappropriate ioctl for device" |
|
201 |
+ container.cmd.Stdin = ptySlave |
|
205 | 202 |
container.cmd.SysProcAttr = &syscall.SysProcAttr{Setctty: true, Setsid: true} |
206 | 203 |
go func() { |
207 | 204 |
defer container.stdin.Close() |
208 | 205 |
Debugf("[startPty] Begin of stdin pipe") |
209 |
- io.Copy(stdoutMaster, container.stdin) |
|
206 |
+ io.Copy(ptyMaster, container.stdin) |
|
210 | 207 |
Debugf("[startPty] End of stdin pipe") |
211 | 208 |
}() |
212 | 209 |
} |
213 | 210 |
if err := container.cmd.Start(); err != nil { |
214 | 211 |
return err |
215 | 212 |
} |
216 |
- stdoutSlave.Close() |
|
213 |
+ ptySlave.Close() |
|
217 | 214 |
return nil |
218 | 215 |
} |
219 | 216 |
|
... | ... |
@@ -507,19 +502,9 @@ func (container *Container) monitor() { |
507 | 507 |
Debugf("%s: Error close stderr: %s", container.Id, err) |
508 | 508 |
} |
509 | 509 |
|
510 |
- if container.ptyStdinMaster != nil { |
|
511 |
- if err := container.ptyStdinMaster.Close(); err != nil { |
|
512 |
- Debugf("%s: Error close pty stdin master: %s", container.Id, err) |
|
513 |
- } |
|
514 |
- } |
|
515 |
- if container.ptyStdoutMaster != nil { |
|
516 |
- if err := container.ptyStdoutMaster.Close(); err != nil { |
|
517 |
- Debugf("%s: Error close pty stdout master: %s", container.Id, err) |
|
518 |
- } |
|
519 |
- } |
|
520 |
- if container.ptyStderrMaster != nil { |
|
521 |
- if err := container.ptyStderrMaster.Close(); err != nil { |
|
522 |
- Debugf("%s: Error close pty stderr master: %s", container.Id, err) |
|
510 |
+ if container.ptyMaster != nil { |
|
511 |
+ if err := container.ptyMaster.Close(); err != nil { |
|
512 |
+ Debugf("%s: Error closing Pty master: %s", container.Id, err) |
|
523 | 513 |
} |
524 | 514 |
} |
525 | 515 |
|