From 672b2047995e0f49f873999743a4158d70a75df7 Mon Sep 17 00:00:00 2001 From: Julien Gilli Date: Tue, 17 Feb 2015 06:34:39 +0000 Subject: [PATCH] tty: fix build for SmartOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Reviewed-By: Ben Noordhuis --- src/unix/tty.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/unix/tty.c b/src/unix/tty.c index a1ea433f..b1782df9 100644 --- a/src/unix/tty.c +++ b/src/unix/tty.c @@ -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; }