mirror of https://github.com/docker/docs.git
Fix termcaps on the linux client
This commit is contained in:
parent
e4a69b1044
commit
50bee2f811
|
@ -255,6 +255,9 @@ func (container *Container) Start() error {
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
if container.Config.Tty {
|
if container.Config.Tty {
|
||||||
|
container.cmd.Env = append(container.Config.Env,
|
||||||
|
"TERM="+os.Getenv("TERM"),
|
||||||
|
)
|
||||||
err = container.startPty()
|
err = container.startPty()
|
||||||
} else {
|
} else {
|
||||||
err = container.start()
|
err = container.start()
|
||||||
|
|
|
@ -1,10 +1,31 @@
|
||||||
package term
|
package term
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"os"
|
||||||
"unsafe"
|
"syscall"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// #include <termios.h>
|
||||||
|
// #include <sys/ioctl.h>
|
||||||
|
/*
|
||||||
|
void MakeRaw() {
|
||||||
|
struct termios t;
|
||||||
|
|
||||||
|
// FIXME: Handle errors?
|
||||||
|
ioctl(0, TCGETS, &t);
|
||||||
|
|
||||||
|
t.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON);
|
||||||
|
t.c_oflag &= ~OPOST;
|
||||||
|
t.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
|
||||||
|
t.c_cflag &= ~(CSIZE | PARENB);
|
||||||
|
t.c_cflag |= CS8;
|
||||||
|
|
||||||
|
ioctl(0, TCSETS, &t);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
getTermios = syscall.TCGETS
|
getTermios = syscall.TCGETS
|
||||||
setTermios = syscall.TCSETS
|
setTermios = syscall.TCSETS
|
||||||
|
@ -14,19 +35,28 @@ const (
|
||||||
// mode and returns the previous state of the terminal so that it can be
|
// mode and returns the previous state of the terminal so that it can be
|
||||||
// restored.
|
// restored.
|
||||||
func MakeRaw(fd int) (*State, error) {
|
func MakeRaw(fd int) (*State, error) {
|
||||||
var oldState State
|
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
newState := oldState.termios
|
fd = int(os.Stdin.Fd())
|
||||||
newState.Iflag &^= ISTRIP | IXON | IXOFF
|
|
||||||
newState.Iflag |= ICRNL
|
|
||||||
newState.Oflag |= ONLCR
|
|
||||||
newState.Lflag &^= ECHO | ICANON | ISIG
|
|
||||||
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(setTermios), uintptr(unsafe.Pointer(&newState)), 0, 0, 0); err != 0 {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return &oldState, nil
|
var oldState State
|
||||||
}
|
if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TCGETS, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
C.MakeRaw()
|
||||||
|
return &oldState, nil
|
||||||
|
|
||||||
|
// FIXME: post on goland issues this: very same as the C function bug non-working
|
||||||
|
|
||||||
|
// newState := oldState.termios
|
||||||
|
|
||||||
|
// newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON)
|
||||||
|
// newState.Oflag &^= OPOST
|
||||||
|
// newState.Lflag &^= (ECHO | syscall.ECHONL | ICANON | ISIG | IEXTEN)
|
||||||
|
// newState.Cflag &^= (CSIZE | syscall.PARENB)
|
||||||
|
// newState.Cflag |= CS8
|
||||||
|
|
||||||
|
// if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TCSETS, uintptr(unsafe.Pointer(&newState))); err != 0 {
|
||||||
|
// return nil, err
|
||||||
|
// }
|
||||||
|
// return &oldState, nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue