Skip to content

Instantly share code, notes, and snippets.

@zhsj
Last active September 3, 2017 06:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhsj/bf0e50258de3c8034a5a0f3a0a4a5b49 to your computer and use it in GitHub Desktop.
Save zhsj/bf0e50258de3c8034a5a0f3a0a4a5b49 to your computer and use it in GitHub Desktop.
go syscall bug
go version go1.9 linux/amd64 (from Debian unstable)
$ strace ./test 2>&1|grep ioctl
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
go version go1.8.1 gccgo (Debian 7.2.0-1) 7.2.0 linux/amd64
$ strace ./test 2>&1|grep ioctl
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
ioctl(0, TCGETS, {B9600 opost isig icanon echo ...}) = 0
go version go1.9 linux/ppc64le (from Debian unstable)
$ strace ./test 2>&1|grep ioctl
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, _IOC(_IOC_READ, 0x74, 0x13, 0x3c), 0xc208014080) = -1 ENOTTY (Inappropriate ioctl for device)
go version go1.8.1 gccgo (Debian 7.2.0-2) 7.2.0 linux/ppc64le
$ strace ./test 2>&1|grep ioctl
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, _IOC(_IOC_READ, 0x74, 0x13, 0x3c), 0xc208014080) = -1 ENOTTY (Inappropriate ioctl for device)
package main
/*
#include<unistd.h>
*/
import "C"
import (
"syscall"
"unsafe"
)
func main() {
C.isatty(C.int(0))
var termios syscall.Termios
syscall.RawSyscall(syscall.SYS_IOCTL, 0, uintptr(syscall.TCGETS), uintptr(unsafe.Pointer(&termios)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment