1 Provide PTY packet mode support for vte in OI.
3 Backported from upstream.
5 See https://gitlab.gnome.org/GNOME/vte/-/commit/8586e4292e76943a100a8039f5ce9e33e5984bb3
8 --- vte-0.54.5/configure.ac.~1~ 2019-10-11 11:54:58.000000000 +0000
9 +++ vte-0.54.5/configure.ac 2020-12-03 11:47:45.207001347 +0000
11 AC_DEFINE_UNQUOTED(VTE_DEFAULT_TERM,"$VTE_DEFAULT_TERM",[The default value $TERM is set to.])
14 -AC_CHECK_HEADERS([sys/select.h sys/syslimits.h sys/termios.h sys/wait.h stropts.h termios.h util.h wchar.h pty.h])
15 +AC_CHECK_HEADERS([sys/select.h sys/stream.h sys/syslimits.h sys/termios.h sys/wait.h stropts.h termios.h util.h wchar.h pty.h])
18 # Check for how to open a new PTY. We support posix_openpt and BSDs openpty
19 --- vte-0.54.5/src/pty.cc.~1~ 2019-10-11 20:09:36.000000000 +0000
20 +++ vte-0.54.5/src/pty.cc 2020-12-03 17:50:14.681738503 +0000
27 /* tty_ioctl(4) -> every read() gives an extra byte at the beginning
28 * notifying us of stop/start (^S/^Q) events. */
30 - return ioctl(fd, TIOCPKT, &one);
31 + ret = ioctl(fd, TIOCPKT, &one);
32 +#elif defined(__sun) && defined(HAVE_STROPTS_H)
33 + if (isastream(fd) == 1 &&
34 + ioctl(fd, I_FIND, "pckt") == 0)
35 + ret = ioctl(fd, I_PUSH, "pckt");
42 if (fd_set_cpkt(fd) < 0) {
43 vte::util::restore_errno errsv;
44 _vte_debug_print(VTE_DEBUG_PTY,
45 - "%s failed: %s", "ioctl(TIOCPKT)", g_strerror(errsv));
46 + "%s failed: %s", "Setting packet mode", g_strerror(errsv));
51 if (fd_set_cpkt(fd) < 0) {
52 vte::util::restore_errno errsv;
53 _vte_debug_print(VTE_DEBUG_PTY,
54 - "%s failed: %s", "ioctl(TIOCPKT)", g_strerror(errsv));
55 + "%s failed: %s", "Setting packet mode", g_strerror(errsv));
59 --- vte-0.54.5/src/vte.cc.~1~ 2019-10-11 20:09:36.000000000 +0000
60 +++ vte-0.54.5/src/vte.cc 2020-12-03 17:50:14.686156151 +0000
62 #ifdef HAVE_SYS_TERMIOS_H
63 #include <sys/termios.h>
65 +#ifdef HAVE_STROPTS_H
68 +#ifdef HAVE_SYS_STREAM_H
69 +#include <sys/stream.h>
73 #include <glib/gi18n-lib.h>
75 bp = chunk->data + chunk->len;
79 /* We'd like to read (fd, bp, rem); but due to TIOCPKT mode
80 * there's an extra input byte returned at the beginning.
81 * We need to see what that byte is, but otherwise drop it
82 @@ -3944,6 +3951,66 @@
86 +#elif defined(__sun) && defined(HAVE_STROPTS_H)
87 + static unsigned char ctl_s[128];
88 + struct strbuf ctlbuf, databuf;
90 + bool have_data = false;
92 + ctlbuf.buf = (caddr_t)ctl_s;
93 + ctlbuf.maxlen = sizeof(ctl_s);
94 + databuf.buf = (caddr_t)bp;
95 + databuf.maxlen = rem;
97 + ret = getmsg(fd, &ctlbuf, &databuf, &flags);
101 + } else if (ctlbuf.len == 1) {
102 + switch (ctl_s[0]) {
104 + pty_termios_changed();
107 + pty_scroll_lock_changed(true);
110 + pty_scroll_lock_changed(false);
116 + } else if (ctlbuf.len == -1 && databuf.len != -1) {
122 + if (databuf.len == 0) {
127 + rem -= databuf.len;
128 + len += databuf.len;
130 +#else /* no TIOCPKT && no STREAMS pty */
131 + int ret = read(fd, bp, rem);