diff options
| author | Ned T. Crigler <crigler@users.sourceforge.net> | 2012-07-26 23:37:49 +0000 |
|---|---|---|
| committer | Ned T. Crigler <crigler@users.sourceforge.net> | 2012-07-26 23:37:49 +0000 |
| commit | b5b466f9823b0ae30a85b08c5db54d7be9241b59 (patch) | |
| tree | c532daef0fe0a24f636e8c4eca93281fc2cc72ff | |
| parent | b87fa9970de6a97bdb6afa442267783adc147f4b (diff) | |
Add AIX support to openpty and forkpty.
Patch by Ross Mohn.
| -rw-r--r-- | master.c | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -597,6 +597,18 @@ openpty(int *amaster, int *aslave, char *name, struct termios *termp, int master, slave; char *buf; +#ifdef _AIX + master = open("/dev/ptc", O_RDWR|O_NOCTTY); + if (master < 0) + return -1; + buf = ttyname(master); + if (!buf) + return -1; + + slave = open(buf, O_RDWR|O_NOCTTY); + if (slave < 0) + return -1; +#else master = open("/dev/ptmx", O_RDWR); if (master < 0) return -1; @@ -618,6 +630,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *termp, if (ioctl(slave, I_PUSH, "ldterm") < 0) return -1; #endif +#endif *amaster = master; *aslave = slave; @@ -661,6 +674,27 @@ forkpty(int *amaster, char *name, struct termios *termp, buf = NULL; if (ioctl(slave, TIOCSCTTY, NULL) < 0) _exit(1); +#elif defined(_AIX) + fd = open("/dev/tty", O_RDWR|O_NOCTTY); + if (fd >= 0) + { + ioctl(fd, TIOCNOTTY, NULL); + close(fd); + } + + buf = ttyname(master); + fd = open(buf, O_RDWR); + close(fd); + + fd = open("/dev/tty", O_WRONLY); + if (fd < 0) + _exit(1); + close(fd); + + if (termp && tcsetattr(slave, TCSAFLUSH, termp) == -1) + _exit(1); + if (ioctl(slave, TIOCSWINSZ, winp) == -1) + _exit(1); #else buf = ptsname(master); fd = open(buf, O_RDWR); |
