Use termios via CGO

This PR closes  #8653.

The direct calls of `ioctl` for `TCGETS` and `TCSETS` do not work correctly at least on Power, possibly on some other architectures. I replaced the `ioctl` calls with `tcgetattr` and `tcsetattr` of POSIX via CGO.  

In theory, this works on any POSIX system, but CGO does not currently support cross compiling, so I keep the non-CGO code for it.

Signed-off-by: Yohei Ueda <yohei@jp.ibm.com>