Blob


1 #include <u.h>
2 #include <termios.h>
3 #include <sys/termios.h>
4 #include <pty.h>
5 #include <libc.h>
6 #include "9term.h"
8 int
9 getpts(int fd[], char *slave)
10 {
11 openpty(&fd[1], &fd[0], slave, 0, 0);
12 return 0;
13 }
15 int
16 childpty(int fd[], char *slave)
17 {
18 int sfd;
20 close(fd[1]);
21 setsid();
22 sfd = open(slave, ORDWR);
23 if(sfd < 0)
24 sysfatal("open %s: %r\n", slave);
25 if(ioctl(sfd, TIOCSCTTY, 0) < 0)
26 fprint(2, "ioctl TIOCSCTTY: %r\n");
27 return sfd;
28 }
30 struct winsize ows;
32 void
33 updatewinsize(int row, int col, int dx, int dy)
34 {
35 struct winsize ws;
37 ws.ws_row = row;
38 ws.ws_col = col;
39 ws.ws_xpixel = dx;
40 ws.ws_ypixel = dy;
41 if(ws.ws_row != ows.ws_row || ws.ws_col != ows.ws_col)
42 if(ioctl(rcfd[0], TIOCSWINSZ, &ws) < 0)
43 fprint(2, "ioctl: %r\n");
44 ows = ws;
45 }