tty: fix build for SmartOS

On Solaris derivatives, cfmakeraw is not available. Instead, set the
termios flags manually. The set of flags to use so that the behavior of
the terminal is similar to what it is after a call to cfmakeraw was
taken from
http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html.

PR-URL: https://github.com/libuv/libuv/pull/210
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
Julien Gilli 2015-02-17 06:34:39 +00:00 committed by Saúl Ibarra Corretgé
parent ff0316813d
commit 672b204799

View File

@ -103,6 +103,24 @@ skip:
return 0;
}
static void uv__tty_make_raw(struct termios* tio) {
assert(tio != NULL);
#ifdef __sun
/*
* This implementation of cfmakeraw for Solaris and derivatives is taken from
* http://www.perkin.org.uk/posts/solaris-portability-cfmakeraw.html.
*/
tio->c_iflag &= ~(IMAXBEL | IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR |
IGNCR | ICRNL | IXON);
tio->c_oflag &= ~OPOST;
tio->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
tio->c_cflag &= ~(CSIZE | PARENB);
tio->c_cflag |= CS8;
#else
cfmakeraw(tio);
#endif /* #ifdef __sun */
}
int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
struct termios tmp;
@ -138,7 +156,7 @@ int uv_tty_set_mode(uv_tty_t* tty, uv_tty_mode_t mode) {
tmp.c_cc[VTIME] = 0;
break;
case UV_TTY_MODE_IO:
cfmakeraw(&tmp);
uv__tty_make_raw(&tmp);
break;
}