7 /* Nonstandard, but vastly superior to the standard functions */
9 int openpty(int *pm, int *ps, char *name, const struct termios *tio, const struct winsize *ws)
14 m = open("/dev/ptmx", O_RDWR|O_NOCTTY);
17 if (ioctl(m, TIOCSPTLCK, &n) || ioctl (m, TIOCGPTN, &n)) {
22 if (!name) name = buf;
23 snprintf(name, sizeof buf, "/dev/pts/%d", n);
24 if ((s = open(name, O_RDWR|O_NOCTTY)) < 0) {
29 if (tio) tcsetattr(s, TCSANOW, tio);
30 if (ws) ioctl(s, TIOCSWINSZ, ws);