10 getpts(int fd[], char *slave)
12 fd[1] = open("/dev/ptmx", ORDWR);
13 if ((grantpt(fd[1]) < 0) || (unlockpt(fd[1]) < 0))
17 strcpy(slave, ptsname(fd[1]));
19 fd[0] = open(slave, ORDWR);
21 sysfatal("open %s: %r\n", slave);
23 /* set up the right streams modules for a tty */
24 ioctl(fd[0], I_PUSH, "ptem"); /* push ptem */
25 ioctl(fd[0], I_PUSH, "ldterm"); /* push ldterm */
31 childpty(int fd[], char *slave)
37 sfd = open(slave, ORDWR);
39 sysfatal("open %s: %r\n", slave);
46 updatewinsize(int row, int col, int dx, int dy)
54 if(ws.ws_row != ows.ws_row || ws.ws_col != ows.ws_col)
55 if(ioctl(rcfd, TIOCSWINSZ, &ws) < 0)
56 fprint(2, "ioctl TIOCSWINSZ: %r\n");
60 static struct termios ttmode;
65 if(tcgetattr(fd, &ttmode) < 0)
66 fprint(2, "tcgetattr: %r\n");
67 if(debug) fprint(2, "israw %c%c\n",
68 ttmode.c_lflag&ICANON ? 'c' : '-',
69 ttmode.c_lflag&ECHO ? 'e' : '-');
70 return (ttmode.c_lflag&ICANON && ttmode.c_lflags&ECHO);
74 setecho(int fd, int newe)
78 if(tcgetattr(fd, &ttmode) < 0)
79 fprint(2, "tcgetattr: %r\n");
80 old = (ttmode.c_lflag&ECHO)==ECHO;
83 ttmode.c_lflag |= ECHO;
85 ttmode.c_lflag &= ~ECHO;
86 if(tcsetattr(fd, TCSANOW, &ttmode) < 0)
87 fprint(2, "tcsetattr: %r\n");